paulmillr / es6-shim

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

RegExp.prototype.flags cannot be read in Chrome Canary #370

Closed fizker closed 8 years ago

fizker commented 8 years ago

One of the shims adds a getter for RegExp.prototype.flags, and guards against overriding the native by reading the current value.

But reading RegExp.prototype.flags throws an error in Chrome Canary (48.0.2559.0): Uncaught TypeError: RegExp.prototype.global getter called on non-RegExp object.

Note: Chrome Canary requires the Experimental JavaScript flag to be enabled before exposing RegExp.prototype.flags.

mathiasbynens commented 8 years ago

That matches the spec. The error message summarizes it well.

fizker commented 8 years ago

The problem is that our webapp breaks in es6-shim because it tries to test whether or not to shim the feature

ljharb commented 8 years ago

@fizker this is indeed part of the spec - you'll need to use typeof Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags').get !== 'function' to detect it.

fizker commented 8 years ago

@ljharb No, technically you need to use that :P. I have made a PR with it

ljharb commented 8 years ago

ha, touché. i haven't yet updated things to pass in Chrome Canary. Thanks for the PR.

ljharb commented 8 years ago

Fixed in c563abf238df6d08f293cb54903fd4df54d5a885

fizker commented 8 years ago

Perfect :). Do you know when this will get released? I would prefer to get it into production as soon as possible, as the crash was rather nasty.

ljharb commented 8 years ago

I will release it shortly, but it's Chrome Canary - nobody using a canary build should have any expectation of any site working. Chrome Stable won't release with it for many weeks.

fizker commented 8 years ago

Still, I would prefer having more time for testing, as we are not on the newest es6-shim. If I am not mistaken, we are still on a version that uses String#contains rather than String#includes, so a lot of other things could also be breaking changes. Anyway, thanks for the quick turn-around on this issue :)

ljharb commented 8 years ago

aha, that's a very very old version indeed - you will want to upgrade soon. I'll have v0.33.11 out today.

ljharb commented 8 years ago

All set https://github.com/paulmillr/es6-shim/releases/tag/0.33.11

fizker commented 8 years ago

Nice! Thanks :)