Skip to content

Commit 1f79e84

Browse files
committed
add a workaround of a Closure Compiler unsafe optimization, close #972
1 parent 1e01d63 commit 1f79e84

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## Changelog
22
##### Unreleased
3+
- Added a workaround of a Closure Compiler unsafe optimization, [#972](https://github.com/zloirock/core-js/issues/972)
34
- One more fix crashing of `Object.create(null)` on WSH, [#970](https://github.com/zloirock/core-js/issues/970)
45

56
##### 3.16.1 - 2021.08.09
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
var fails = require('../internals/fails');
2+
var global = require('../internals/global');
23

3-
// babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError,
4-
var RE = function (s, f) {
5-
return RegExp(s, f);
6-
};
4+
// babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
5+
var $RegExp = global.RegExp;
76

87
exports.UNSUPPORTED_Y = fails(function () {
9-
var re = RE('a', 'y');
8+
var re = $RegExp('a', 'y');
109
re.lastIndex = 2;
1110
return re.exec('abcd') != null;
1211
});
1312

1413
exports.BROKEN_CARET = fails(function () {
1514
// https://bugzilla.mozilla.org/show_bug.cgi?id=773687
16-
var re = RE('^r', 'gy');
15+
var re = $RegExp('^r', 'gy');
1716
re.lastIndex = 2;
1817
return re.exec('str') != null;
1918
});
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
var fails = require('./fails');
2+
var global = require('../internals/global');
3+
4+
// babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError
5+
var $RegExp = global.RegExp;
26

37
module.exports = fails(function () {
4-
// babel-minify transpiles RegExp('.', 's') -> /./s and it causes SyntaxError
5-
var re = RegExp('.', (typeof '').charAt(0));
8+
var re = $RegExp('.', 's');
69
return !(re.dotAll && re.exec('\n') && re.flags === 's');
710
});
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
var fails = require('./fails');
2+
var global = require('../internals/global');
3+
4+
// babel-minify and Closure Compiler transpiles RegExp('.', 'g') -> /./g and it causes SyntaxError
5+
var $RegExp = global.RegExp;
26

37
module.exports = fails(function () {
4-
// babel-minify transpiles RegExp('.', 'g') -> /./g and it causes SyntaxError
5-
var re = RegExp('(?<a>b)', (typeof '').charAt(5));
8+
var re = $RegExp('(?<a>b)', 'g');
69
return re.exec('b').groups.a !== 'b' ||
710
'b'.replace(re, '$<a>c') !== 'bc';
811
});

0 commit comments

Comments
 (0)