Index: src/string-iterator.js |
diff --git a/src/string-iterator.js b/src/string-iterator.js |
index 7222885a56f465931980d646a277ea9c69cc1abf..e237257e03538c8d7a73995061636de1a95a5b0b 100644 |
--- a/src/string-iterator.js |
+++ b/src/string-iterator.js |
@@ -11,8 +11,10 @@ |
var stringIteratorIteratedStringSymbol = |
- GLOBAL_PRIVATE("StringIterator#iteratedString"); |
-var stringIteratorNextIndexSymbol = GLOBAL_PRIVATE("StringIterator#next"); |
+ GLOBAL_PRIVATE_OWN("StringIterator#iteratedString"); |
+var stringIteratorNextIndexSymbol = GLOBAL_PRIVATE_OWN("StringIterator#next"); |
+ |
+var stringEndOfIterationMarker = new $Object(); |
function StringIterator() {} |
@@ -38,13 +40,13 @@ function StringIteratorIterator() { |
function StringIteratorNext() { |
var iterator = ToObject(this); |
- if (!HAS_PRIVATE(iterator, stringIteratorIteratedStringSymbol)) { |
+ if (!HAS_DEFINED_PRIVATE(iterator, stringIteratorIteratedStringSymbol)) { |
throw MakeTypeError('incompatible_method_receiver', |
['String Iterator.prototype.next']); |
} |
var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol); |
- if (IS_UNDEFINED(s)) { |
+ if (s === stringEndOfIterationMarker) { |
wingo
2014/08/20 15:32:53
Wouldn't stringEndOfIterationMarker be per-realm?
arv (Not doing code reviews)
2014/08/20 15:39:26
You are right. This is not going to work.
I don't
Dmitry Lomov (no reviews)
2014/08/20 17:01:37
Thanks, good catch, I haven't thought of that.
arv (Not doing code reviews)
2014/08/20 18:07:07
In this case and for the ArrayIterator we can chec
|
return CreateIteratorResultObject(UNDEFINED, true); |
} |
@@ -52,7 +54,8 @@ function StringIteratorNext() { |
var length = TO_UINT32(s.length); |
if (position >= length) { |
- SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, UNDEFINED); |
+ SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, |
+ stringEndOfIterationMarker); |
return CreateIteratorResultObject(UNDEFINED, true); |
} |