Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6 Symbol breaks < IE Edge #41

Open
4rn0 opened this issue Mar 22, 2017 · 5 comments
Open

ES6 Symbol breaks < IE Edge #41

4rn0 opened this issue Mar 22, 2017 · 5 comments

Comments

@4rn0
Copy link

4rn0 commented Mar 22, 2017

Hi Stephen,

great work on this project. I just noticed the usage of ES6 Symbols in the source: https://github.com/stephband/jquery.event.move/blob/master/js/jquery.event.move.js#L83

As you might know no IE version except Edge supports this. Any chance on some more IE support or should I just use an ES6-shim?

Cheers!
Arno

@stephband
Copy link
Owner

Oh yeah. I polyfill Symbol, normally, but you're right, I probably shouldn't assume it's existence here.

This code replaces symbols with strings (via .toString when setting the symbol property). It's not a polyfill, but it will get things working in IE:

if (!window.Symbol) {
    (function(window){
        "use strict";

        var defineProperty = Object.defineProperty;
        var prefix = '__symbol-' + Math.ceil(Math.random() * 1000000000) + '-';
        var id = 0;

        function Symbol(description) {
            if (!(this instanceof Symbol)) { return new Symbol(description); }
            var symbol = prefix + id++;
            this._symbol = symbol;
        }

        defineProperty(Symbol.prototype, 'toString', {
            enumerable: false,
            configurable: false,
            writable: false,
            value: function toString() {
                return this._symbol;
            }
        });

        window.Symbol = Symbol;
    }(this));
}

@4rn0
Copy link
Author

4rn0 commented Mar 24, 2017

Works like a charm! Thanks!

@szamanr
Copy link

szamanr commented Mar 21, 2018

@stephband i'm still getting this problem and my app is not running on IE11. could you release a solution as a commit?

i am using jquery.event.move 2.0.0 and jquery 3.3.1.

@andreszs
Copy link

Oh yeah. I polyfill Symbol, normally, but you're right, I probably shouldn't assume it's existence here.

This code replaces symbols with strings (via .toString when setting the symbol property). It's not a polyfill, but it will get things working in IE:

if (!window.Symbol) {
    (function(window){
        "use strict";

        var defineProperty = Object.defineProperty;
        var prefix = '__symbol-' + Math.ceil(Math.random() * 1000000000) + '-';
        var id = 0;

        function Symbol(description) {
            if (!(this instanceof Symbol)) { return new Symbol(description); }
            var symbol = prefix + id++;
            this._symbol = symbol;
        }

        defineProperty(Symbol.prototype, 'toString', {
            enumerable: false,
            configurable: false,
            writable: false,
            value: function toString() {
                return this._symbol;
            }
        });

        window.Symbol = Symbol;
    }(this));
}

Adding this effectively disables vertical scroll in both Internet Explorer 11 Mobile and Edge Mobile (that is, the complete Windows Phone and Windows Mobile device family).

I'll never understand that obsession with the implementation of ES 2015 (and newer) functions with the only goal of rendering scripts unusable in older browsers. Please remember that not everyone can acquire a 1300 USD iPhone device to use the methods from ECMA Script 2020... it's the other way around: scripts must work in older devices whenever possible. Do not take this as a personal attack to the plugin developers, this is just a suggestion.

@Nukro
Copy link

Nukro commented Aug 31, 2020

Oh yeah. I polyfill Symbol, normally, but you're right, I probably shouldn't assume it's existence here.

This code replaces symbols with strings (via .toString when setting the symbol property). It's not a polyfill, but it will get things working in IE:

if (!window.Symbol) {
    (function(window){
        "use strict";

        var defineProperty = Object.defineProperty;
        var prefix = '__symbol-' + Math.ceil(Math.random() * 1000000000) + '-';
        var id = 0;

        function Symbol(description) {
            if (!(this instanceof Symbol)) { return new Symbol(description); }
            var symbol = prefix + id++;
            this._symbol = symbol;
        }

        defineProperty(Symbol.prototype, 'toString', {
            enumerable: false,
            configurable: false,
            writable: false,
            value: function toString() {
                return this._symbol;
            }
        });

        window.Symbol = Symbol;
    }(this));
}

Where to place that code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants