diff --git a/packages/core-js/modules/esnext.regexp.escape.js b/packages/core-js/modules/esnext.regexp.escape.js index a15640545382..0e285c5f8817 100644 --- a/packages/core-js/modules/esnext.regexp.escape.js +++ b/packages/core-js/modules/esnext.regexp.escape.js @@ -7,6 +7,7 @@ var padStart = require('../internals/string-pad').start; var WHITESPACES = require('../internals/whitespaces'); var $Array = Array; +var $escape = RegExp.escape; var charAt = uncurryThis(''.charAt); var charCodeAt = uncurryThis(''.charCodeAt); var numberToString = uncurryThis(1.1.toString); @@ -29,9 +30,12 @@ var escapeChar = function (chr) { return hex.length < 3 ? '\\x' + padStart(hex, 2, '0') : '\\u' + padStart(hex, 4, '0'); }; +// Avoiding the use of polyfills of the previous iteration of this proposal +var FORCED = !!$escape && $escape('ab') !== '\\x61b'; + // `RegExp.escape` method // https://github.com/tc39/proposal-regex-escaping -$({ target: 'RegExp', stat: true }, { +$({ target: 'RegExp', stat: true, forced: FORCED }, { escape: function escape(S) { aString(S); var length = S.length; diff --git a/tests/compat/tests.js b/tests/compat/tests.js index e413323dda12..b139b4635f25 100644 --- a/tests/compat/tests.js +++ b/tests/compat/tests.js @@ -1777,7 +1777,7 @@ GLOBAL.tests = { return Promise['try']; }], 'esnext.regexp.escape': function () { - return RegExp.escape; + return RegExp.escape('ab') === '\\x61b'; }, 'esnext.set.add-all': function () { return Set.prototype.addAll;