-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a workaround of a Closure Compiler unsafe optimization, close #972
- Loading branch information
Showing
4 changed files
with
16 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
var fails = require('../internals/fails'); | ||
var global = require('../internals/global'); | ||
|
||
// babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError, | ||
var RE = function (s, f) { | ||
return RegExp(s, f); | ||
}; | ||
// babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError | ||
var $RegExp = global.RegExp; | ||
|
||
exports.UNSUPPORTED_Y = fails(function () { | ||
var re = RE('a', 'y'); | ||
var re = $RegExp('a', 'y'); | ||
re.lastIndex = 2; | ||
return re.exec('abcd') != null; | ||
}); | ||
|
||
exports.BROKEN_CARET = fails(function () { | ||
// https://bugzilla.mozilla.org/show_bug.cgi?id=773687 | ||
var re = RE('^r', 'gy'); | ||
var re = $RegExp('^r', 'gy'); | ||
re.lastIndex = 2; | ||
return re.exec('str') != null; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
var fails = require('./fails'); | ||
var global = require('../internals/global'); | ||
|
||
// babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError | ||
var $RegExp = global.RegExp; | ||
|
||
module.exports = fails(function () { | ||
// babel-minify transpiles RegExp('.', 's') -> /./s and it causes SyntaxError | ||
var re = RegExp('.', (typeof '').charAt(0)); | ||
var re = $RegExp('.', 's'); | ||
return !(re.dotAll && re.exec('\n') && re.flags === 's'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
var fails = require('./fails'); | ||
var global = require('../internals/global'); | ||
|
||
// babel-minify and Closure Compiler transpiles RegExp('.', 'g') -> /./g and it causes SyntaxError | ||
var $RegExp = global.RegExp; | ||
|
||
module.exports = fails(function () { | ||
// babel-minify transpiles RegExp('.', 'g') -> /./g and it causes SyntaxError | ||
var re = RegExp('(?<a>b)', (typeof '').charAt(5)); | ||
var re = $RegExp('(?<a>b)', 'g'); | ||
return re.exec('b').groups.a !== 'b' || | ||
'b'.replace(re, '$<a>c') !== 'bc'; | ||
}); |