10000 Consider a prototype-free object a map. Fixes #302 · powercoder23/immutable-js@923a41e · GitHub
[go: up one dir, main page]

Skip to content

Commit 923a41e

Browse files
committed
Consider a prototype-free object a map. Fixes immutable-js#302
1 parent ee38270 commit 923a41e

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

__tests__/Conversion.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ describe('Conversion', () => {
4545
a: "A",
4646
b: "B"
4747
},
48+
emptyMap: Object.create(null),
4849
point: {x: 10, y: 20},
4950
string: "Hello",
5051
list: [1, 2, 3]
@@ -68,6 +69,7 @@ describe('Conversion', () => {
6869
a: "A",
6970
b: "B"
7071
}),
72+
emptyMap: Map(),
7173
point: Map({x: 10, y: 20}),
7274
string: "Hello",
7375
list: List.of(1, 2, 3)
@@ -89,6 +91,7 @@ describe('Conversion', () => {
8991
a: "A",
9092
b: "B"
9193
}),
94+
emptyMap: OrderedMap(),
9295
point: new Point({x: 10, y: 20}),
9396
string: "Hello",
9497
list: List.of(1, 2, 3)
@@ -110,6 +113,7 @@ describe('Conversion', () => {
110113
'a: "A", '+
111114
'b: "B"'+
112115
' }, '+
116+
'emptyMap: OrderedMap {}, ' +
113117
'point: Point { x: 10, y: 20 }, '+
114118
'string: "Hello", '+
115119
'list: List [ 1, 2, 3 ]'+

dist/immutable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@
724724
}
725725

726726
function isPlainObj(value) {
727-
return value && value.constructor === Object;
727+
return value && (value.constructor === Object || value.constructor === undefined);
728728
}
729729

730730
var Math__imul =

dist/immutable.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/fromJS.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ function fromJSDefault(json) {
3636
}
3737

3838
function isPlainObj(value) {
39-
return value && value.constructor === Object;
39+
return value && (value.constructor === Object || value.constructor === undefined);
4040
}

0 commit comments

Comments
 (0)
0