Skip to content

Commit

Permalink
Merge pull request 903
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Kogut committed Apr 1, 2017
2 parents e140aad + 7f4a20a commit 1b229f5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/types/observablemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export type IObservableMapInitialValues<V> = IMapEntries<V> | IKeyValueMap<V> |

export class ObservableMap<V> implements IInterceptable<IMapWillChange<V>>, IListenable, IMap<string, V> {
$mobx = ObservableMapMarker;
private _data: { [key: string]: ObservableValue<V | undefined> } = {};
private _hasMap: { [key: string]: ObservableValue<boolean> } = {}; // hasMap, not hashMap >-).
private _data: { [key: string]: ObservableValue<V | undefined> } = Object.create(null);
private _hasMap: { [key: string]: ObservableValue<boolean> } = Object.create(null); // hasMap, not hashMap >-).
private _keys: IObservableArray<string> = <any> new ObservableArray(undefined, referenceEnhancer, `${this.name}.keys()`, true);
interceptors = null;
changeListeners = null;
Expand Down
17 changes: 17 additions & 0 deletions test/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,3 +603,20 @@ test('using deep map', t => {

t.end();
});

test("issue 893", t => {
const m = mobx.observable.map();
const keys = ['constructor', 'toString', 'assertValidKey', 'isValidKey', 'toJSON', 'toJS']
for (let key of keys) {
t.equal(m.get(key), undefined);
}
t.end();
});

test("work with 'toString' key", t => {
const m = mobx.observable.map();
t.equal(m.get('toString'), undefined);
m.set('toString', 'test');
t.equal(m.get('toString'), 'test');
t.end();
});

0 comments on commit 1b229f5

Please sign in to comment.