-
Stage 3 Draft / August 9, 2018
+
Stage 3 Draft / December 7, 2018
String.prototype.matchAll
@@ -2213,7 +2213,7 @@ 1String.prototype.matchAll ( regexp )
Performs a regular expression match of the String representing the this value against regexp and returns an iterator. Each iteration result’s value is an Array object containing the results of the match, or null if the String did not match.
When the matchAll
method is called, the following steps are taken:
- - Let O be ? RequireObjectCoercible(this value).
- If regexp is neither undefined nor null, then
- Let matcher be ? GetMethod(regexp, @@matchAll).
- If matcher is not undefined, then
- Return ? Call(matcher, regexp, « O »).
- Let S be ? ToString(O).
- Let matcher be ? RegExpCreate(R,
"g"
). - Let global be true.
- Let fullUnicode be false.
- Return ! CreateRegExpStringIterator(matcher, S, global, fullUnicode).
+
- Let O be ? RequireObjectCoercible(this value).
- If regexp is neither undefined nor null, then
- Let matcher be ? GetMethod(regexp, @@matchAll).
- If matcher is not undefined, then
- Return ? Call(matcher, regexp, « O »).
- Let S be ? ToString(O).
- Let rx be ? RegExpCreate(regexp,
"g"
). - Return ? Invoke(rx, @@matchAll, « S »).
Note 1The matchAll
function is intentionally generic, it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
Note 2Similarly to String.prototype.split
, String.prototype.matchAll
is designed to typically act without mutating its inputs.
diff --git a/spec.emu b/spec.emu
index d88cefc..84c8b75 100644
--- a/spec.emu
+++ b/spec.emu
@@ -21,10 +21,8 @@ contributors: Jordan Harband
1. If _matcher_ is not *undefined*, then
1. Return ? Call(_matcher_, _regexp_, « _O_ »).
1. Let _S_ be ? ToString(_O_).
- 1. Let _matcher_ be ? RegExpCreate(_R_, `"g"`).
- 1. Let _global_ be *true*.
- 1. Let _fullUnicode_ be *false*.
- 1. Return ! CreateRegExpStringIterator(_matcher_, _S_, _global_, _fullUnicode_).
+ 1. Let _rx_ be ? RegExpCreate(_regexp_, `"g"`).
+ 1. Return ? Invoke(_rx_, @@matchAll, « _S_ »).
The `matchAll` function is intentionally generic, it does not require that its *this* value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
Similarly to `String.prototype.split`, `String.prototype.matchAll` is designed to typically act without mutating its inputs.
diff --git a/spec.md b/spec.md
index 0f1e337..2a26f59 100644
--- a/spec.md
+++ b/spec.md
@@ -9,10 +9,8 @@ When the `matchAll` method is called, the following steps are taken:
1. If *matcher* is not **undefined**, then
1. Return ? [Call](call)(*matcher*, *regexp*, « *O* »).
1. Let *S* be ? [ToString][tostring](*O*).
- 1. Let *matcher* be ? [RegExpCreate][regexp-create](*R*, `"g"`).
- 1. Let *global* be **true**.
- 1. Let *fullUnicode* be **false**.
- 1. Return ! [CreateRegExpStringIterator](#createregexpstringiterator-abstract-operation)(*matcher*, *S*, *global*, *fullUnicode*).
+ 1. Let *rx* be ? [RegExpCreate][regexp-create](*regexp*, `"g"`).
+ 1. Return ? [Invoke][invoke](*rx*, @@matchAll, « *S* »).
Note 1: The `matchAll` function is intentionally generic, it does not require that its *this* value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
Note 2: Similarly to `String.prototype.split`, `String.prototype.matchAll` is designed to typically act without mutating its inputs.
@@ -171,3 +169,4 @@ This property has the attributes { [[Writable]]: **false**, [[Enumerable]]: **fa
[tolength]: https://tc39.github.io/ecma262/#sec-tolength
[set]: https://tc39.github.io/ecma262/#sec-set-o-p-v-throw
[to-boolean]: https://tc39.github.io/ecma262/#sec-toboolean
+[invoke]: https://tc39.github.io/ecma262/#sec-invoke