Skip to content

Commit

Permalink
Fix map construction
Browse files Browse the repository at this point in the history
  • Loading branch information
davecoates committed Jul 27, 2016
1 parent aeaf5fb commit 653c07f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ export const Map = function(keyDescriptor, valueDescriptor, label) {
const type = new EntryType(keyType, valueType, label)

const MapType = function(value) {
const isThis = this instanceof MapType
const constructor = isThis ? this.constructor : MapType
const isMapType = this instanceof MapType
const constructor = isMapType ? this.constructor : MapType

if (value instanceof constructor) {
return value
Expand All @@ -262,9 +262,7 @@ export const Map = function(keyDescriptor, valueDescriptor, label) {
throw result
}

const isCall = isThis && construct.prototype === this

if (!isCall && isThis) {
if (isMapType && !this[$store]) {
this[$store] = result[$store]
this.size = result.size
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/test/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ test('is persistent to updateIn', assert => {
assert.throws(() => m2.updateIn(['level1', 'a'], 5))
assert.throws(() => m2.updateIn(['level1', 5], 'a'))
assert.throws(() => m2.updateIn([1, 'a'], 'a'))
assert.deepEquals(m1.toJS(), {a: 'a', b: 'b'})
assert.deepEquals(m2.toJS(), {level1: {a: 'a', b: 'b'}})
assert.deepEquals(m3.toJS(), {level1: {a: 'aa', b: 'b'}})
assert.deepEquals(m4.toJS(), {level1: {a: 'aaaa', b: 'b'}})
})
Expand Down

0 comments on commit 653c07f

Please sign in to comment.