_notifySplice adds an attribute named 'splices' to arrays
The following code
Polymer({
is: 'x-qwe',
properties: {
data: {
type: Array,
value: function() {
return [];
}
}
},
attached: function() {
this.splice('data', 1, 0, { name: 'TEST' });
console.log(JSON.stringify(this.data.splices));
}
});
returns {"keySplices":null,"indexSplices":null}
Looks like the bug is in this.set(path + '.splices', change):
set: function(path, value, root) {
var prop = root || this;
var parts = this._getPathParts(path);
var array;
var last = parts[parts.length-1];
if (parts.length > 1) {
for (var i=0; i<parts.length-1; i++) {
var part = parts[i];
prop = prop[part];
if (array && (parseInt(part) == part)) {
parts[i] = Polymer.Collection.get(array).getKey(prop);
}
if (!prop) {
return;
}
array = Array.isArray(prop) ? prop : null;
}
if (array && (parseInt(last) == last)) {
var coll = Polymer.Collection.get(array);
var old = prop[last];
var key = coll.getKey(old);
parts[i] = key;
coll.setItem(key, value);
}
prop[last] = value; // <<< HERE
if (!root) {
this.notifyPath(parts.join('.'), value);
}
} else {
prop[path] = value;
}
},
I'm observing something similar when changing an array via:
this.push('array', item);
When observing array.splices I get a change record with correct base and path properties, but keySplices and arraySplices are null.
Polymer is up to date. Any help is appreciated.
+1
Looks like this was fixed in https://github.com/Polymer/polymer/pull/3439, and i can no longer repro in in v1.latest:
https://jsbin.com/voritiduse/1/edit?html,output
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.