Skip to content

Commit 28152b7

Browse files
committed
Prefer static method that hides isTracked detail.
1 parent 3e0a448 commit 28152b7

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/lib/collection.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
return items;
9797
},
9898

99-
applySplices: function(splices) {
99+
_applySplices: function(splices) {
100100
var keySplices = [];
101101
for (var i=0; i<splices.length; i++) {
102102
var j, o, key, s = splices[i];
@@ -132,8 +132,11 @@
132132
|| new Polymer.Collection(userArray);
133133
};
134134

135-
Polymer.Collection.isTracked = function(userArray) {
136-
return Polymer._collections.has(userArray);
135+
Polymer.Collection.applySplices = function(userArray, splices) {
136+
// Only apply splices & generate keySplices if the array already has a
137+
// backing Collection, meaning there is an element monitoring its keys
138+
var coll = Polymer._collections.get(userArray);
139+
return coll ? coll._applySplices(splices) : null;
137140
};
138141

139142
</script>

src/lib/experimental/observe-js-behavior.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@
7676
observer = new ArrayObserver(object);
7777
observer.open(function(splices) {
7878
this._notifyObserveJsPath(els, 'splices', {
79-
keySplices: Polymer.Collection.isTracked(object) ?
80-
Polymer.Collection.get(object).applySplices(splices) : null,
79+
keySplices: Polymer.Collection.applySplices(object, splices),
8180
indexSplices: splices
8281
});
8382
}, this);

src/standard/notify-path.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,7 @@
332332
type: 'splice'
333333
}];
334334
var change = {
335-
keySplices: Polymer.Collection.isTracked(array) ?
336-
Polymer.Collection.get(array).applySplices(splices) : null,
335+
keySplices: Polymer.Collection.applySplices(array, splices),
337336
indexSplices: splices
338337
};
339338
this.set(path + '.splices', change);

0 commit comments

Comments
 (0)