diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-12-06 23:39:47 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-12-06 23:39:47 +0100 |
commit | 642032029f65e9dc0d38fbb6d35ef656c73a292c (patch) | |
tree | 78a22bd12d679ab532db490d631ee69fa085aec1 /js/src/builtin/String.js | |
parent | 50ef259a2df60d020ccb02d76dc5aa4835ee319e (diff) | |
parent | 2529b2edece0a0ed86553d1e73eef13c3848bf64 (diff) | |
download | UXP-642032029f65e9dc0d38fbb6d35ef656c73a292c.tar UXP-642032029f65e9dc0d38fbb6d35ef656c73a292c.tar.gz UXP-642032029f65e9dc0d38fbb6d35ef656c73a292c.tar.lz UXP-642032029f65e9dc0d38fbb6d35ef656c73a292c.tar.xz UXP-642032029f65e9dc0d38fbb6d35ef656c73a292c.zip |
Merge branch 'master' into release
Diffstat (limited to 'js/src/builtin/String.js')
-rw-r--r-- | js/src/builtin/String.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/js/src/builtin/String.js b/js/src/builtin/String.js index f830b1aa2..d07ec6127 100644 --- a/js/src/builtin/String.js +++ b/js/src/builtin/String.js @@ -63,6 +63,33 @@ function String_generic_match(thisValue, regexp) { return callFunction(String_match, thisValue, regexp); } +// String.prototype.matchAll proposal. +// +// String.prototype.matchAll ( regexp ) +function String_matchAll(regexp) { + // Step 1. + RequireObjectCoercible(this); + + // Step 2. + if (regexp !== undefined && regexp !== null) { + // Step 2.a. + var matcher = GetMethod(regexp, std_matchAll); + + // Step 2.b. + if (matcher !== undefined) + return callContentFunction(matcher, regexp, this); + } + + // Step 3. + var string = ToString(this); + + // Step 4. + var rx = RegExpCreate(regexp, "g"); + + // Step 5. + return callContentFunction(GetMethod(rx, std_matchAll), rx, string); +} + /** * A helper function implementing the logic for both String.prototype.padStart * and String.prototype.padEnd as described in ES7 Draft March 29, 2016 |