fix String.prototype.{ match, search } polyfills conversion order

This commit is contained in:
Denis Pushkarev
2026-04-10 12:01:17 +03:00
parent 7b327e75fd
commit b1a946a0d4
3 changed files with 7 additions and 2 deletions
+3 -1
View File
@@ -22,7 +22,9 @@ fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNa
function match(regexp) {
var O = requireObjectCoercible(this);
var matcher = isObject(regexp) ? getMethod(regexp, MATCH) : undefined;
return matcher ? call(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString(O));
if (matcher) return call(matcher, regexp, O);
var S = toString(O);
return new RegExp(regexp)[MATCH](S);
},
// `RegExp.prototype[@@match]` method
// https://tc39.es/ecma262/#sec-regexp.prototype-@@match
+3 -1
View File
@@ -17,7 +17,9 @@ fixRegExpWellKnownSymbolLogic('search', function (SEARCH, nativeSearch, maybeCal
function search(regexp) {
var O = requireObjectCoercible(this);
var searcher = isObject(regexp) ? getMethod(regexp, SEARCH) : undefined;
return searcher ? call(searcher, regexp, O) : new RegExp(regexp)[SEARCH](toString(O));
if (searcher) return call(searcher, regexp, O);
var S = toString(O);
return new RegExp(regexp)[SEARCH](S);
},
// `RegExp.prototype[@@search]` method
// https://tc39.es/ecma262/#sec-regexp.prototype-@@search