Index: src/string-iterator.js |
diff --git a/src/string-iterator.js b/src/string-iterator.js |
index 7222885a56f465931980d646a277ea9c69cc1abf..dc2aeee2c7c38c9a56dd099ef33b511420ef5333 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 (IS_PRIVATE_OWN_UNDEFINED(iterator, stringIteratorIteratedStringSymbol)) { |
throw MakeTypeError('incompatible_method_receiver', |
['String Iterator.prototype.next']); |
} |
var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol); |
- if (IS_UNDEFINED(s)) { |
+ if (s === stringEndOfIterationMarker) { |
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); |
} |