Skip to content

Commit

Permalink
Fixed #1258: cannot replace map contents using another map
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Dec 4, 2017
1 parent afee132 commit 9c14059
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.3.3

* Fixed regression bug where observable map contents could not be replaced using another observable map [#1258](https://github.com/mobxjs/mobx/issues/1258)

# 3.3.2

* Fix bug where custom comparers could be invoked with `undefined` values. Fixes [#1208](https://github.com/mobxjs/mobx/issues/1208)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export function getEnumerableKeys(obj) {
export function deepEqual(a, b) {
if (a === null && b === null) return true
if (a === undefined && b === undefined) return true
if (areBothNaN(a, b)) return true
if (areBothNaN(a, b)) return true
if (typeof a !== "object") return a === b
const aIsArray = isArrayLike(a)
const aIsMap = isMapLike(a)
Expand Down Expand Up @@ -217,7 +217,7 @@ export function getMapLikeKeys<V>(map: ObservableMap<V> | IKeyValueMap<V> | any)
let keys;
if (isPlainObject(map)) keys = Object.keys(map)
else if (Array.isArray(map)) keys = map.map(([key]) => key)
else if (isES6Map(map)) keys = (Array as any).from(map.keys())
else if (isMapLike(map)) keys = (Array as any).from(map.keys())
else fail("Cannot get keys from " + map)
return keys;
}
Expand Down
7 changes: 7 additions & 0 deletions test/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,3 +678,10 @@ test("issue 1243, .replace should not trigger change on unchanged values", t =>
d()
t.end()
})

test("#1258 cannot replace maps anymore", t => {
const items = mobx.observable.map()
items.replace(mobx.observable.map())

t.end()
})

0 comments on commit 9c14059

Please sign in to comment.