Skip to content

Commit e8e99b6

Browse files
committed
Fix initialization
1 parent e7f504a commit e8e99b6

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

polyfill.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = MapPoly = function (/*iterable*/) {
2727
__mapKeysData__: d('c', keys = []),
2828
__mapValuesData__: d('c', values = [])
2929
});
30-
if (!iterable) return;
30+
if (!iterable) return self;
3131
forOf(iterable, function (value) {
3232
var key = validValue(value)[0];
3333
value = value[1];

primitive/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = PrimitiveMap = function (/*iterable, serialize*/) {
3232
__mapValuesData__: d('c', create(null)),
3333
__size__: d('w', 0)
3434
});
35-
if (!iterable) return;
35+
if (!iterable) return self;
3636
forOf(iterable, function (value) {
3737
var key = validValue(value)[0], sKey = self._serialize(key);
3838
if (sKey == null) throw new TypeError(key + " cannot be serialized");

test/polyfill.js

+6
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,10 @@ module.exports = function (T, a) {
5151
a(map.size, 0, "Clear: size");
5252
a(map.has('trzy'), false, "Clear: has");
5353
a.deep(toArray(map), [], "Clear: Values");
54+
55+
a.h1("Empty initialization");
56+
map = new T();
57+
map.set('foo', 'bar');
58+
a(map.size, 1);
59+
a(map.get('foo'), 'bar');
5460
};

test/primitive/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,10 @@ module.exports = function (T, a) {
5050
a(map.size, 0, "Clear: size");
5151
a(map.has('trzy'), false, "Clear: has");
5252
a.deep(toArray(map.values()), [], "Clear: Values");
53+
54+
a.h1("Empty initialization");
55+
map = new T();
56+
map.set('foo', 'bar');
57+
a(map.size, 1);
58+
a(map.get('foo'), 'bar');
5359
};

0 commit comments

Comments
 (0)