-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Give correct RegExp flags in toString #537
Conversation
I think that there should be something like var R = anObject(this);
var p = String(R.source);
var rf = R.flags;
var f = String(rf === undefined && R instanceof RegExp && !('flags' in RegExpPrototype) ? flags.call(R) : rf);
return '/' + p + '/' + f; |
@zloirock Thanks for looking over this. I've read these parts of the spec now so have a slightly better understanding. In your suggested implementation, I'm not sure I understand the purpose of checking https://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.flags On the tests, I have a plan that would sort of work, but is likely too big a change for this branch. Main issue is the tests are always run in a browser context that includes the whole polyfill bundle:
<script src='../packages/core-js-bundle/index.js'></script>
<!-- ... -->
<script src='./bundles/tests.js'></script> It would be possible to change tests: {
entry: './tests/tests/index.js',
output: { filename: 'tests.js' },
}, That would then make it possible to test each file with only its own polyfill rather than all of core-js. That still doesn't help if the tests are run on a modern chrome where the feature is implemented anyway, but is heading in a sensible direction? |
It can be called on non-regex or a |
You have correctly identified a problem of testing. However, the problem is deeper than you think - for example, a big part of modules are not independent and should work in different ways in different combinations and those combinations defined in many different places like CommonJS entry point, |
00651cd
to
54f790e
Compare
@zloirock Have poked around and can't come up with a scenario that doesn't work correctly with the |
When the flags property is not available on RegExp, the internals regexp-flags implementation should be used regardless of DESCRIPTORS. Fixes: zloirock#536
54f790e
to
5f8e75b
Compare
@zloirock Have updated with basic proxy test (that would have failed on non-flags browsers only) and that spelling. Does seem like the same form should be used in |
When the flags property is not available on
RegExp
, the internalsregexp-flags
implementation should be used regardless ofDESCRIPTORS
.Fixes: #536
I'm not certain this is the right fix, but the value of
DESCRIPTORS
istrue
on IE 11 and the internals implementation would be fine - and doesn't seem to depend ondefineProperty
.Also not sure how to include a focused test, but the linked issue has a project that reproduces the problem.