Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Remove PreviousIndex checking; ensure only global creates multiple …
Browse files Browse the repository at this point in the history
…matches

Per #29 (comment)
  • Loading branch information
ljharb committed Dec 14, 2017
1 parent 08f6369 commit af51902
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 41 deletions.
14 changes: 5 additions & 9 deletions index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 4 additions & 16 deletions spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,11 @@ contributors: Jordan Harband
1. Assert: Type(_S_) is String.
1. Assert: Type(_global_) is Boolean.
1. Assert: Type(_fullUnicode_) is Boolean.
1. Let _iterator_ be ObjectCreate(<emu-xref href="#%RegExpStringIteratorPrototype%">%RegExpStringIteratorPrototype%</emu-xref>, &laquo; [[IteratingRegExp]], [[IteratedString]], [[PreviousIndex]], [[Done]] &raquo;).
1. Let _iterator_ be ObjectCreate(<emu-xref href="#%RegExpStringIteratorPrototype%">%RegExpStringIteratorPrototype%</emu-xref>, &laquo; [[IteratingRegExp]], [[IteratedString]], [[Done]] &raquo;).
1. Set _iterator_.[[IteratingRegExp]] to _R_.
1. Set _iterator_.[[IteratedString]] to _S_.
1. Set _iterator_.[[Global]] to _global_.
1. Set _iterator_.[[Unicode]] to _fullUnicode_.
1. Set _iterator_.[[PreviousIndex]] to *-1*.
1. Set _iterator_.[[Done]] to *false*.
1. Return _iterator_.
</emu-alg>
Expand Down Expand Up @@ -115,15 +114,8 @@ contributors: Jordan Harband
1. Perform ? Set(_R_, *"lastIndex"*, _nextIndex_, *true*).
1. Return ! CreateIterResultObject(_match_, *false*).
1. Else,
1. Let _previousIndex_ be _O_.[[PreviousIndex]].
1. Assert: Type(_previousIndex_) is Number.
1. Let _index_ be ? ToLength(? Get(_match_, *"index"*)).
1. If _previousIndex_ is equal to _index_, then
1. Set _O_.[[Done]] to *true*.
1. Return ! CreateIterResultObject(*null*, *true*).
1. Else,
1. Set _O_.[[PreviousIndex]] to _index_.
1. Return ! CreateIterResultObject(_match_, *false*).
1. Set _O_.[[Done]] to *true*.
1. Return ! CreateIterResultObject(_match_, *false*).
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -158,11 +150,7 @@ contributors: Jordan Harband
</tr>
<tr>
<td>[[Unicode]]</td>
<td>A Boolean value to indicate whether the [[IteratingRegExp]] is in full Unicode mode or not.</td>
</tr>
<tr>
<td>[[PreviousIndex]]</td>
<td>The index of the previous yielded match object, for non-global regular expressions.</td>
<td>A Boolean value to indicate whether the [[IteratingRegExp]] is in Unicode mode or not.</td>
</tr>
<tr>
<td>[[Done]]</td>
Expand Down
20 changes: 4 additions & 16 deletions spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ The abstract operation *CreateRegExpStringIterator* is used to create such itera
1. Assert: [Type][type](*S*) is String.
1. Assert: [Type][type](*global*) is Boolean.
1. Assert: [Type][type](*unicode*) is Boolean.
1. Let *iterator* be ObjectCreate(<emu-xref href="#%RegExpStringIteratorPrototype%">%RegExpStringIteratorPrototype%</emu-xref>, « [[IteratedString]], [[IteratingRegExp]], [[PreviousIndex]], [[Done]] »).
1. Let *iterator* be ObjectCreate(<emu-xref href="#%RegExpStringIteratorPrototype%">%RegExpStringIteratorPrototype%</emu-xref>, « [[IteratedString]], [[IteratingRegExp]], [[Done]] »).
1. Set *iterator*.[[IteratingRegExp]] to *R*.
1. Set *iterator*.[[IteratedString]] to *S*.
1. Set *iterator*.[[Global]] to *global*.
1. Set *iterator*.[[Unicode]] to *fullUnicode*.
1. Set *iterator*.[[PreviousIndex]] to **-1**.
1. Set *iterator*.[[Done]] to **true**.
1. Return *iterator*.

Expand Down Expand Up @@ -80,15 +79,8 @@ All RegExp String Iterator Objects inherit properties from the [%RegExpStringIte
1. Perform ? [Set][set](*R*, **"lastIndex"**, *nextIndex*, **true**).
1. Return ! [CreateIterResultObject][create-iter-result-object](*match*, **false**).
1. Else,
1. Let *previousIndex* be *O*.[[PreviousIndex]].
1. Assert: Type(*previousIndex*) is Number.
1. Let *index* be ? [ToLength][tolength](? [Get][get](*match*, **"index"**).
1. If *previousIndex* is equal to *index*, then
1. Set *O*.[[Done]] to **true**.
1. Return ! [CreateIterResultObject][create-iter-result-object](**null**, **true**).
1. Else,
1. Set *O*.[[PreviousIndex]] to *index*.
1. Return ! [CreateIterResultObject][create-iter-result-object](_match_, **false**).
1. Set *O*.[[Done]] to **true**.
1. Return ! [CreateIterResultObject][create-iter-result-object](_match_, **false**).

#### %RegExpStringIteratorPrototype%[ @@toStringTag ]

Expand Down Expand Up @@ -121,11 +113,7 @@ RegExp String Iterator instances are ordinary objects that inherit properties fr
</tr>
<tr>
<td>[[Unicode]]</td>
<td>A Boolean value to indicate whether the [[IteratingRegExp]] is in full Unicode more or not.</td>
</tr>
<tr>
<td>[[PreviousIndex]]</td>
<td>The index of the previous yielded match object.</td>
<td>A Boolean value to indicate whether the [[IteratingRegExp]] is in Unicode mode or not.</td>
</tr>
<tr>
<td>[[Done]]</td>
Expand Down

0 comments on commit af51902

Please sign in to comment.