From e9639380161d7fa0b015ab929a3f013deea1d2aa Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Tue, 19 May 2015 14:42:11 +0200 Subject: [PATCH] Do not attach collection to index if duplicate. --- packages/xo-collection/src/collection.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/xo-collection/src/collection.js b/packages/xo-collection/src/collection.js index 72de3294e..c2f2684ff 100644 --- a/packages/xo-collection/src/collection.js +++ b/packages/xo-collection/src/collection.js @@ -178,14 +178,15 @@ export default class Collection extends EventEmitter { // ----------------------------------------------------------------- createIndex (name, index) { - index._attachCollection(this) - const {_indexes: indexes} = this if (hasOwnProperty.call(indexes, name)) { throw new DuplicateIndex(name) } + indexes[name] = index this._indexedItems[name] = index.items + + index._attachCollection(this) } deleteIndex (name) {