paulmillr / es6-shim

ECMAScript 6 compatibility shims for legacy JS engines
http://paulmillr.com
MIT License
3.11k stars 387 forks source link

ES6-Shim should not return Symbol.iterator instead of Array in Firefox when using with #384

Closed timcosta closed 8 years ago

timcosta commented 8 years ago

See https://jsfiddle.net/dfqve80a/3/ in Firefox and Chrome for an example of the problem

Essentially, if you load es6-shim and then run the following code, the output should be [1,2,3] instead of Symbol.iterator.

var fxn = function(values) {
    with(values) {
        return values;
    }
}
console.log( fxn([1,2,3]) ); // Symbol.iterator in Firefox

This may also be affecting IE, however I do not have a version of IE handy to test with currently.

ljharb commented 8 years ago

This relates to the behavior of Symbol.unscopables, which browsers don't usually implement correctly, and is unshimmable. Try the same with "values" and "entries" - you'll see it's the actual function it's pulling off of the array.

At any rate this isn't caused nor exacerbated by es6-shim, and is impossible to fix in JS.

ljharb commented 8 years ago

(This shouldn't come up in real code, though, because nobody should ever be using the with statement for any reason)

timcosta commented 8 years ago

Unfortunately ExtJs 3.1.1 uses the exact function in the JsFiddle. Thanks for the information though, its going to be quite valuable while we work to solve this.

ljharb commented 8 years ago

I would highly discourage using any libraries or frameworks that use the with statement in 2015. ExtJS is up to 6.0, so if you're on 3.1.1 you may wish to upgrade - 3.0 came out in 2009, and as such, is ancient.

timcosta commented 8 years ago

You don't have to tell me that haha. We are working to get away from it, but sometimes there are things higher up on the priority list.

ljharb commented 8 years ago

I can't imagine what would be higher on the priority list than using 6 year old outdated software that is broken in modern browsers, but it's not up to me I guess :-)

timcosta commented 8 years ago

If it ain't broke and the clients want other things, it's not high priority haha. Now that it has a known fault it'll likely be reevaluated.

rwaldron commented 8 years ago

ExtJs is the exact reason that unscopables exists—for the exact code that was cited here.

ljharb commented 8 years ago

@rwaldron aha, i had a hunch that was the case. does that mean that Firefox should have a bug filed re unscopables?