From d785d58eb77677e71615e35eb85832b3b0a19b3c Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 18 Oct 2017 10:45:22 +0200 Subject: [PATCH 1/2] Fix Map#concat #1373 made `Map#concat` an alias for `Map#merge` but defined the alias before `Map#merge` was defined, resulting in `Map#concat` being undefined. This fixes the issue and adds a regression test. --- __tests__/Map.ts | 8 ++++++++ src/Map.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/__tests__/Map.ts b/__tests__/Map.ts index 509517e108..66af8a01cd 100644 --- a/__tests__/Map.ts +++ b/__tests__/Map.ts @@ -129,6 +129,14 @@ describe('Map', () => { expect(m3.toObject()).toEqual({a: 'A', b: 'BB', c: 'C', wow: 'OO', d: 'DD'}); }); + it('concatenates two maps (alias for merge)', () => { + const m1 = Map({ a: 'A', b: 'B', c: 'C' }); + const m2 = Map({ wow: 'OO', d: 'DD', b: 'BB' }); + expect(m2.toObject()).toEqual({ wow: 'OO', d: 'DD', b: 'BB' }); + const m3 = m1.concat(m2); + expect(m3.toObject()).toEqual({a: 'A', b: 'BB', c: 'C', wow: 'OO', d: 'DD'}); + }); + it('accepts null as a key', () => { const m1 = Map(); const m2 = m1.set(null, 'null'); diff --git a/src/Map.js b/src/Map.js index 750ea81a8b..e73626786f 100644 --- a/src/Map.js +++ b/src/Map.js @@ -170,7 +170,7 @@ export const MapPrototype = Map.prototype; MapPrototype[IS_MAP_SENTINEL] = true; MapPrototype[DELETE] = MapPrototype.remove; MapPrototype.removeAll = MapPrototype.deleteAll; -MapPrototype.concat = MapPrototype.merge; +MapPrototype.concat = merge; MapPrototype.setIn = setIn; MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; MapPrototype.update = update; From 1d2907b8f84789575b473e888bc1147bf2bdb975 Mon Sep 17 00:00:00 2001 From: Lee Byron Date: Wed, 18 Oct 2017 12:39:06 -0700 Subject: [PATCH 2/2] Alias on same line --- src/Map.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Map.js b/src/Map.js index e73626786f..035a0d42e4 100644 --- a/src/Map.js +++ b/src/Map.js @@ -170,12 +170,11 @@ export const MapPrototype = Map.prototype; MapPrototype[IS_MAP_SENTINEL] = true; MapPrototype[DELETE] = MapPrototype.remove; MapPrototype.removeAll = MapPrototype.deleteAll; -MapPrototype.concat = merge; MapPrototype.setIn = setIn; MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; MapPrototype.update = update; MapPrototype.updateIn = updateIn; -MapPrototype.merge = merge; +MapPrototype.merge = MapPrototype.concat = merge; MapPrototype.mergeWith = mergeWith; MapPrototype.mergeDeep = mergeDeep; MapPrototype.mergeDeepWith = mergeDeepWith;