Skip to content

Commit

Permalink
Add finer control of properties copied to subcollections
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Payton committed Nov 11, 2014
1 parent 66972ca commit 041bf6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 2 additions & 8 deletions Memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,8 @@ define([
});
},

_createSubCollection: function () {
var subCollection = this.inherited(arguments);

// Make sure a .data property is not carried over from this collection
// to corrupt the results of the new collection
subCollection.data = undefined;

return subCollection;
_includePropertyInSubCollection: function (name) {
return name !== 'data' && this.inherited(arguments);
}
});
});
6 changes: 5 additions & 1 deletion Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,18 @@ define([
var newCollection = lang.delegate(this.constructor.prototype);

for (var i in this) {
if (!(i in newCollection) || newCollection[i] !== this[i]) {
if (this._includePropertyInSubCollection(i, newCollection)) {
newCollection[i] = this[i];
}
}

return declare.safeMixin(newCollection, kwArgs);
},

_includePropertyInSubCollection: function (name, subCollection) {
return !(name in subCollection) || subCollection[name] !== this[name];
},

// queryLog: __QueryLogEntry[]
// The query operations represented by this collection
queryLog: [], // NOTE: It's ok to define this on the prototype because the array instance is never modified
Expand Down

0 comments on commit 041bf6a

Please sign in to comment.