Skip to content

Commit

Permalink
some missed actions for #732
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Dec 17, 2019
1 parent 80d7bfe commit ff4f391
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Changelog
##### Unreleased
- Added support of sticky (`y`) `RegExp` flag, [#372](https://github.com/zloirock/core-js/issues/372), [#732](https://github.com/zloirock/core-js/issues/732), [#492](https://github.com/zloirock/core-js/issues/492), thanks @cvle and @nicolo-ribaudo
- Added `RegExp#test` delegation to `RegExp#exec`, [#732](https://github.com/zloirock/core-js/issues/732), thanks @cvle
- Fixed some cases of `Object.create(null)` in IE8-, [#727](https://github.com/zloirock/core-js/issues/727), [#728](https://github.com/zloirock/core-js/issues/728), thanks @aleen42
- Allowed object of minimum environment versions as `core-js-compat` and `core-js-builder` `targets` argument
- Allowed corresponding to Babel `targets.esmodules`, `targets.browsers`, `targets.node` options in `core-js-compat` and `core-js-builder`
Expand Down
2 changes: 1 addition & 1 deletion packages/core-js-compat/src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,8 @@ const data = {
},
'es.regexp.exec': {
chrome: '26',
firefox: '44',
edge: '13',
firefox: '44',
safari: '10.0',
},
'es.regexp.flags': {
Expand Down
4 changes: 4 additions & 0 deletions packages/core-js-compat/src/modules-by-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ module.exports = {
'esnext.object.iterate-keys',
'esnext.object.iterate-values',
],
3.6: [
'es.regexp.sticky',
'es.regexp.test',
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty
1 change: 1 addition & 0 deletions packages/core-js-pure/override/modules/es.regexp.sticky.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty
1 change: 1 addition & 0 deletions packages/core-js-pure/override/modules/es.regexp.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty
5 changes: 5 additions & 0 deletions packages/core-js/es/regexp/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require('../../modules/es.regexp.test');

module.exports = function (re, string) {
return RegExp.prototype.test.call(re, string);
};
3 changes: 3 additions & 0 deletions packages/core-js/features/regexp/sticky.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var parent = require('../../es/regexp/sticky');

module.exports = parent;
3 changes: 3 additions & 0 deletions packages/core-js/features/regexp/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var parent = require('../../es/regexp/test');

module.exports = parent;
5 changes: 3 additions & 2 deletions packages/core-js/modules/es.regexp.constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ if (FORCED) {
var thisIsRegExp = this instanceof RegExpWrapper;
var patternIsRegExp = isRegExp(pattern);
var flagsAreUndefined = flags === undefined;
var sticky;

if (!thisIsRegExp && patternIsRegExp && pattern.constructor === RegExpWrapper && flagsAreUndefined) {
return pattern;
Expand All @@ -50,7 +51,7 @@ if (FORCED) {
}

if (UNSUPPORTED_Y) {
var sticky = !!flags && flags.indexOf('y') > -1;
sticky = !!flags && flags.indexOf('y') > -1;
if (sticky) flags = flags.replace(/y/g, '');
}

Expand All @@ -60,7 +61,7 @@ if (FORCED) {
RegExpWrapper
);

if (UNSUPPORTED_Y) setInternalState(result, { sticky: sticky });
if (UNSUPPORTED_Y && sticky) setInternalState(result, { sticky: sticky });

return result;
};
Expand Down
3 changes: 3 additions & 0 deletions packages/core-js/stable/regexp/sticky.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var parent = require('../../es/regexp/sticky');

module.exports = parent;
3 changes: 3 additions & 0 deletions packages/core-js/stable/regexp/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var parent = require('../../es/regexp/test');

module.exports = parent;
6 changes: 6 additions & 0 deletions tests/commonjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ for (const _PATH of ['../packages/core-js-pure', '../packages/core-js']) {
ok(typeof load('features/regexp/replace') === 'function');
ok(typeof load('features/regexp/search') === 'function');
ok(typeof load('features/regexp/split') === 'function');
ok(typeof load('features/regexp/sticky') === 'function');
ok(typeof load('features/regexp/test') === 'function');
load('features/regexp');
ok(load('features/json').stringify([1]) === '[1]');
ok(load('features/json/stringify')([1]) === '[1]');
Expand Down Expand Up @@ -620,6 +622,8 @@ for (const _PATH of ['../packages/core-js-pure', '../packages/core-js']) {
ok(typeof load('stable/regexp/replace') === 'function');
ok(typeof load('stable/regexp/search') === 'function');
ok(typeof load('stable/regexp/split') === 'function');
ok(typeof load('stable/regexp/sticky') === 'function');
ok(typeof load('stable/regexp/test') === 'function');
load('stable/regexp');
ok(load('stable/json').stringify([1]) === '[1]');
ok(load('stable/json/stringify')([1]) === '[1]');
Expand Down Expand Up @@ -885,6 +889,8 @@ for (const _PATH of ['../packages/core-js-pure', '../packages/core-js']) {
ok(typeof load('es/regexp/replace') === 'function');
ok(typeof load('es/regexp/search') === 'function');
ok(typeof load('es/regexp/split') === 'function');
ok(typeof load('es/regexp/sticky') === 'function');
ok(typeof load('es/regexp/test') === 'function');
load('es/regexp');
ok(load('es/json').stringify([1]) === '[1]');
ok(load('es/json/stringify')([1]) === '[1]');
Expand Down

0 comments on commit ff4f391

Please sign in to comment.