2
2
// TODO: Remove from `core-js@4` since it's moved to entry points
3
3
require ( '../modules/es.regexp.exec' ) ;
4
4
var redefine = require ( '../internals/redefine' ) ;
5
+ var regexpExec = require ( '../internals/regexp-exec' ) ;
5
6
var fails = require ( '../internals/fails' ) ;
6
7
var wellKnownSymbol = require ( '../internals/well-known-symbol' ) ;
7
8
var createNonEnumerableProperty = require ( '../internals/create-non-enumerable-property' ) ;
8
9
9
10
var SPECIES = wellKnownSymbol ( 'species' ) ;
11
+ var RegExpPrototype = RegExp . prototype ;
10
12
11
13
var REPLACE_SUPPORTS_NAMED_GROUPS = ! fails ( function ( ) {
12
14
// #replace needs built-in support for named groups.
@@ -94,7 +96,8 @@ module.exports = function (KEY, length, exec, sham) {
94
96
) {
95
97
var nativeRegExpMethod = / ./ [ SYMBOL ] ;
96
98
var methods = exec ( SYMBOL , '' [ KEY ] , function ( nativeMethod , regexp , str , arg2 , forceStringMethod ) {
97
- if ( regexp . exec === RegExp . prototype . exec ) {
99
+ var $exec = regexp . exec ;
100
+ if ( $exec === regexpExec || $exec === RegExpPrototype . exec ) {
98
101
if ( DELEGATES_TO_SYMBOL && ! forceStringMethod ) {
99
102
// The native String method already delegates to @@method (this
100
103
// polyfilled function), leasing to infinite recursion.
@@ -112,7 +115,7 @@ module.exports = function (KEY, length, exec, sham) {
112
115
var regexMethod = methods [ 1 ] ;
113
116
114
117
redefine ( String . prototype , KEY , stringMethod ) ;
115
- redefine ( RegExp . prototype , SYMBOL , length == 2
118
+ redefine ( RegExpPrototype , SYMBOL , length == 2
116
119
// 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
117
120
// 21.2.5.11 RegExp.prototype[@@split](string, limit)
118
121
? function ( string , arg ) { return regexMethod . call ( string , this , arg ) ; }
@@ -122,5 +125,5 @@ module.exports = function (KEY, length, exec, sham) {
122
125
) ;
123
126
}
124
127
125
- if ( sham ) createNonEnumerableProperty ( RegExp . prototype [ SYMBOL ] , 'sham' , true ) ;
128
+ if ( sham ) createNonEnumerableProperty ( RegExpPrototype [ SYMBOL ] , 'sham' , true ) ;
126
129
} ;
0 commit comments