From 24c40b583687e6f67ba57e6c8927515ceb5399ce Mon Sep 17 00:00:00 2001 From: meatloaf Date: Wed, 3 Feb 2021 20:53:17 -0600 Subject: Issue #1726 - Implement String.replaceAll() This also implements IsRegExp, as this demands it. Ported from https://bugzilla.mozilla.org/show_bug.cgi?id=1540021 --- js/src/builtin/RegExp.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'js/src/builtin/RegExp.js') diff --git a/js/src/builtin/RegExp.js b/js/src/builtin/RegExp.js index 91212066c..7218fc0e8 100644 --- a/js/src/builtin/RegExp.js +++ b/js/src/builtin/RegExp.js @@ -1166,3 +1166,24 @@ function RegExpStringIteratorNext() { result.value = match; return result; } + +// String.prototype.matchAll proposal. +// ES2020 draft rev e97c95d064750fb949b6778584702dd658cf5624 +// 7.2.8 IsRegExp ( argument ) +function IsRegExp(argument) { + // Step 1. + if (!IsObject(argument)) { + return false; + } + + // Step 2. + var matcher = argument[std_match]; + + // Step 3. + if (matcher !== undefined) { + return !!matcher; + } + + // Steps 4-5. + return IsPossiblyWrappedRegExpObject(argument); +} -- cgit v1.2.3