settings.js not working in IE8
comede opened this issue · 6 comments
When using global settings via <script type="application/x-social-share-privacy-settings">
, the script settings.js throws an error in IE8.
I changed line 17 from:
var settings = (new Function('return ('+$.text(this)+');')).call(this);
to
var settings = (new Function("return (" + this.text + ");")).call();
Now it works fine in IE8. Testet in IE8 and Safari. Other browsers are not yet tested.
This won't work in all browsers. It probably should be something like (this.text || this.textContent || this.innerText)
.
Yes. Inspired by your solution i went back to the original Code enhanced by fallback:
var settings = (new Function('return ('+ ($.text(this) || this.textContent || this.innerText || this.text) +');')).call(this);
I tested a slightly different Version with the original jQuery.text()-Call and the native element-property-access as Fallback in IE 7,8,9,10, FF3, FF25, Chrome on Windows and Safari7 and FF23 on Mac:
/**
* @license
* jquery.socialshareprivacy.js | 2 Klicks fuer mehr Datenschutz
*
* Copyright (c) 2012-2013 Mathias Panzenböck
*
* is released under the MIT License http://www.opensource.org/licenses/mit-license.php
*
* Spread the word, link to us if you can.
*/
// load global settings
jQuery(document).ready(function () {
"use strict";
jQuery('script[type="application/x-social-share-privacy-settings"]').each(function () {
var settings = (new Function('return ('+ (jQuery.text(this) || this.textContent || this.innerText || this.text) +');')).call(this);
if (typeof settings === "object") {
jQuery.extend(true, jQuery.fn.socialSharePrivacy.settings, settings);
}
});
});
I use jQuery instead of $ to be prepared to use the script in no-conflict Mode.
IE 7 additional throws an error when there is a comma not followed by another item but by closing curly brace in the settings-section. This could be critical when building the settings inside an CMS-Module.
Great.
IE 7 additional throws an error when there is a comma not followed by another item but by closing curly brace in the settings-section.
Well, I think this is correct behavior. Anyway, that's out of my control. It would be invalid JSON anyway.
Well, I think this is correct behavior. Anyway, that's out of my control. It would be invalid JSON anyway.
Yes it is. Just a hint to save debug-time ;-)