@@ -10,47 +10,7 @@ var createNonEnumerableProperty = require('../internals/create-non-enumerable-pr
10
10
var SPECIES = wellKnownSymbol ( 'species' ) ;
11
11
var RegExpPrototype = RegExp . prototype ;
12
12
13
- var REPLACE_SUPPORTS_NAMED_GROUPS = ! fails ( function ( ) {
14
- // #replace needs built-in support for named groups.
15
- // #match works fine because it just return the exec results, even if it has
16
- // a "grops" property.
17
- var re = / ./ ;
18
- re . exec = function ( ) {
19
- var result = [ ] ;
20
- result . groups = { a : '7' } ;
21
- return result ;
22
- } ;
23
- return '' . replace ( re , '$<a>' ) !== '7' ;
24
- } ) ;
25
-
26
- // IE <= 11 replaces $0 with the whole match, as if it was $&
27
- // https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0
28
- var REPLACE_KEEPS_$0 = ( function ( ) {
29
- // eslint-disable-next-line regexp/prefer-escape-replacement-dollar-char -- required for testing
30
- return 'a' . replace ( / ./ , '$0' ) === '$0' ;
31
- } ) ( ) ;
32
-
33
- var REPLACE = wellKnownSymbol ( 'replace' ) ;
34
- // Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string
35
- var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = ( function ( ) {
36
- if ( / ./ [ REPLACE ] ) {
37
- return / ./ [ REPLACE ] ( 'a' , '$0' ) === '' ;
38
- }
39
- return false ;
40
- } ) ( ) ;
41
-
42
- // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
43
- // Weex JS has frozen built-in prototypes, so use try / catch wrapper
44
- var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = ! fails ( function ( ) {
45
- // eslint-disable-next-line regexp/no-empty-group -- required for testing
46
- var re = / (?: ) / ;
47
- var originalExec = re . exec ;
48
- re . exec = function ( ) { return originalExec . apply ( this , arguments ) ; } ;
49
- var result = 'ab' . split ( re ) ;
50
- return result . length !== 2 || result [ 0 ] !== 'a' || result [ 1 ] !== 'b' ;
51
- } ) ;
52
-
53
- module . exports = function ( KEY , length , exec , sham ) {
13
+ module . exports = function ( KEY , length , exec , FORCED , sham ) {
54
14
var SYMBOL = wellKnownSymbol ( KEY ) ;
55
15
56
16
var DELEGATES_TO_SYMBOL = ! fails ( function ( ) {
@@ -87,12 +47,7 @@ module.exports = function (KEY, length, exec, sham) {
87
47
if (
88
48
! DELEGATES_TO_SYMBOL ||
89
49
! DELEGATES_TO_EXEC ||
90
- ( KEY === 'replace' && ! (
91
- REPLACE_SUPPORTS_NAMED_GROUPS &&
92
- REPLACE_KEEPS_$0 &&
93
- ! REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE
94
- ) ) ||
95
- ( KEY === 'split' && ! SPLIT_WORKS_WITH_OVERWRITTEN_EXEC )
50
+ FORCED
96
51
) {
97
52
var nativeRegExpMethod = / ./ [ SYMBOL ] ;
98
53
var methods = exec ( SYMBOL , '' [ KEY ] , function ( nativeMethod , regexp , str , arg2 , forceStringMethod ) {
@@ -107,9 +62,6 @@ module.exports = function (KEY, length, exec, sham) {
107
62
return { done : true , value : nativeMethod . call ( str , regexp , arg2 ) } ;
108
63
}
109
64
return { done : false } ;
110
- } , {
111
- REPLACE_KEEPS_$0 : REPLACE_KEEPS_$0 ,
112
- REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE : REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE
113
65
} ) ;
114
66
var stringMethod = methods [ 0 ] ;
115
67
var regexMethod = methods [ 1 ] ;
0 commit comments