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

String#matchAll polyfill should throw on non-global regex #3517

Closed
teppeis opened this issue Dec 10, 2019 · 1 comment
Closed

String#matchAll polyfill should throw on non-global regex #3517

teppeis opened this issue Dec 10, 2019 · 1 comment
Assignees
Labels
internal-issue-created An internal Google issue has been created to track this GitHub issue triage-done Has been reviewed by someone on triage rotation.

Comments

@teppeis
Copy link
Contributor

teppeis commented Dec 10, 2019

"foo".matchAll(/foo/) should throw but current polyfill doesn't.
Previously it didn't throw, but spec was changed on Oct 2019 TC39 meeting.

// The spec says it should be an error to pass a non-global RegExp to
// matchAll, but MDN and Chrome agree that a single match should be done
// instead.
var matchOnlyOnce = regexp instanceof RegExp && !regexp.global;

but MDN and Chrome agree that a single match should be done instead.

MDN is not updated yet.
Chrome 80, Firefox 73, Safari TP and core-js have already implemented the new behavior.
https://kangax.github.io/compat-table/es2016plus/

I think Closure Compiler polyfill should follow the latest spec and major browsers.

@brad4d
Copy link
Contributor

brad4d commented Dec 10, 2019

Thanks for pointing this out.
We noticed the discrepancy, but decided to implement what our current Chrome browser & MDN said the behavior should be while we gathered more info.

I actually got a response from the v8 team and had just filed a bug requesting we change our polyfill behavior just before I saw this GitHub issue.

@rrdelaney rrdelaney added triage-done Has been reviewed by someone on triage rotation. internal-issue-created An internal Google issue has been created to track this GitHub issue labels Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal-issue-created An internal Google issue has been created to track this GitHub issue triage-done Has been reviewed by someone on triage rotation.
Projects
None yet
Development

No branches or pull requests

4 participants