22// TODO: Remove from `core-js@4` since it's moved to entry points
33require ( '../modules/es.regexp.exec' ) ;
44var redefine = require ( '../internals/redefine' ) ;
5+ var regexpExec = require ( '../internals/regexp-exec' ) ;
56var fails = require ( '../internals/fails' ) ;
67var wellKnownSymbol = require ( '../internals/well-known-symbol' ) ;
78var createNonEnumerableProperty = require ( '../internals/create-non-enumerable-property' ) ;
89
910var SPECIES = wellKnownSymbol ( 'species' ) ;
11+ var RegExpPrototype = RegExp . prototype ;
1012
1113var REPLACE_SUPPORTS_NAMED_GROUPS = ! fails ( function ( ) {
1214 // #replace needs built-in support for named groups.
@@ -94,7 +96,8 @@ module.exports = function (KEY, length, exec, sham) {
9496 ) {
9597 var nativeRegExpMethod = / ./ [ SYMBOL ] ;
9698 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 ) {
98101 if ( DELEGATES_TO_SYMBOL && ! forceStringMethod ) {
99102 // The native String method already delegates to @@method (this
100103 // polyfilled function), leasing to infinite recursion.
@@ -112,7 +115,7 @@ module.exports = function (KEY, length, exec, sham) {
112115 var regexMethod = methods [ 1 ] ;
113116
114117 redefine ( String . prototype , KEY , stringMethod ) ;
115- redefine ( RegExp . prototype , SYMBOL , length == 2
118+ redefine ( RegExpPrototype , SYMBOL , length == 2
116119 // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
117120 // 21.2.5.11 RegExp.prototype[@@split](string, limit)
118121 ? function ( string , arg ) { return regexMethod . call ( string , this , arg ) ; }
@@ -122,5 +125,5 @@ module.exports = function (KEY, length, exec, sham) {
122125 ) ;
123126 }
124127
125- if ( sham ) createNonEnumerableProperty ( RegExp . prototype [ SYMBOL ] , 'sham' , true ) ;
128+ if ( sham ) createNonEnumerableProperty ( RegExpPrototype [ SYMBOL ] , 'sham' , true ) ;
126129} ;
0 commit comments