Index: src/collection.js |
diff --git a/src/collection.js b/src/collection.js |
index 20887dd8f7adf5f4ae61c0919c8afbd09469e341..0027bd732041f94ccf81dbfe3256c4f75d680c5a 100644 |
--- a/src/collection.js |
+++ b/src/collection.js |
@@ -49,6 +49,13 @@ function SetAddJS(key) { |
throw MakeTypeError('incompatible_method_receiver', |
['Set.prototype.add', this]); |
} |
+ // Normalize -0 to +0 as required by the spec. |
+ // Even though we use SameValueZero as the comparison for the keys we don't |
+ // want to ever store -0 as the key since the key is directly exposed when |
+ // doing iteration. |
+ if (key === 0) { |
+ key = 0; |
+ } |
return %SetAdd(this, key); |
} |
@@ -186,6 +193,13 @@ function MapSetJS(key, value) { |
throw MakeTypeError('incompatible_method_receiver', |
['Map.prototype.set', this]); |
} |
+ // Normalize -0 to +0 as required by the spec. |
+ // Even though we use SameValueZero as the comparison for the keys we don't |
+ // want to ever store -0 as the key since the key is directly exposed when |
+ // doing iteration. |
+ if (key === 0) { |
+ key = 0; |
+ } |
return %MapSet(this, key, value); |
} |