diff --git a/src/lib/bind/accessors.html b/src/lib/bind/accessors.html
index 3c769ecc73..4d82b56e20 100644
--- a/src/lib/bind/accessors.html
+++ b/src/lib/bind/accessors.html
@@ -212,7 +212,7 @@
return function(e, target) {
if (!bogusTest(e, target)) {
if (e.detail && e.detail.path) {
- this.notifyPath(this._fixPath(path, property, e.detail.path),
+ this._notifyPath(this._fixPath(path, property, e.detail.path),
e.detail.value);
} else {
var value = target[property];
diff --git a/src/lib/collection.html b/src/lib/collection.html
index e89fc1d2ad..fc3bdbe2ef 100644
--- a/src/lib/collection.html
+++ b/src/lib/collection.html
@@ -70,10 +70,14 @@
},
getKey: function(item) {
+ var key;
if (item && typeof item == 'object') {
- return '#' + this.omap.get(item);
+ key = this.omap.get(item);
} else {
- return '#' + this.pmap[item];
+ key = this.pmap[item];
+ }
+ if (key != undefined) {
+ return '#' + key;
}
},
diff --git a/src/lib/template/array-selector.html b/src/lib/template/array-selector.html
index 84fe2e0578..f728e3fd33 100644
--- a/src/lib/template/array-selector.html
+++ b/src/lib/template/array-selector.html
@@ -130,6 +130,7 @@
}
} else {
this.unlinkPaths('selected');
+ this.unlinkPaths('selectedItem');
}
// Initialize selection
if (this.multi) {
diff --git a/src/lib/template/dom-if.html b/src/lib/template/dom-if.html
index 7c5e049177..56ab20a36c 100644
--- a/src/lib/template/dom-if.html
+++ b/src/lib/template/dom-if.html
@@ -160,7 +160,7 @@
// notifying parent. path change on each row
_forwardParentPath: function(path, value) {
if (this._instance) {
- this._instance.notifyPath(path, value, true);
+ this._instance._notifyPath(path, value, true);
}
}
diff --git a/src/lib/template/dom-repeat.html b/src/lib/template/dom-repeat.html
index ee3e99ed18..0a56ed7891 100644
--- a/src/lib/template/dom-repeat.html
+++ b/src/lib/template/dom-repeat.html
@@ -605,7 +605,7 @@
// for notifying items.. change up to host
_forwardInstancePath: function(inst, path, value) {
if (path.indexOf(this.as + '.') === 0) {
- this.notifyPath('items.' + inst.__key__ + '.' +
+ this._notifyPath('items.' + inst.__key__ + '.' +
path.slice(this.as.length + 1), value);
}
},
@@ -624,7 +624,7 @@
// notifying parent path change on each inst
_forwardParentPath: function(path, value) {
this._instances.forEach(function(inst) {
- inst.notifyPath(path, value, true);
+ inst._notifyPath(path, value, true);
}, this);
},
@@ -639,7 +639,7 @@
if (inst) {
if (dot >= 0) {
path = this.as + '.' + path.substring(dot+1);
- inst.notifyPath(path, value, true);
+ inst._notifyPath(path, value, true);
} else {
inst.__setProperty(this.as, value, true);
}
diff --git a/src/lib/template/templatizer.html b/src/lib/template/templatizer.html
index 37478f59c4..9466bca24b 100644
--- a/src/lib/template/templatizer.html
+++ b/src/lib/template/templatizer.html
@@ -119,7 +119,7 @@
archetype._prepBindings();
// boilerplate code
- archetype._notifyPath = this._notifyPathImpl;
+ archetype._notifyPathUp = this._notifyPathUpImpl;
archetype._scopeElementClass = this._scopeElementClassImpl;
archetype.listen = this._listenImpl;
archetype._showHideChildren = this._showHideChildrenImpl;
@@ -292,7 +292,7 @@
// _forwardParentPath: function(path, value) { },
// _forwardParentProp: function(prop, value) { },
- _notifyPathImpl: function(path, value) {
+ _notifyPathUpImpl: function(path, value) {
var dataHost = this.dataHost;
var dot = path.indexOf('.');
var root = dot < 0 ? path : path.slice(0, dot);
diff --git a/src/standard/notify-path.html b/src/standard/notify-path.html
index af58b91d5e..a8801f6d82 100644
--- a/src/standard/notify-path.html
+++ b/src/standard/notify-path.html
@@ -65,10 +65,12 @@
Polymer.Base._addFeature({
/**
- * Notify that a path has changed. For example:
+ * Notify that a path has changed.
*
- * this.item.user.name = 'Bob';
- * this.notifyPath('item.user.name', this.item.user.name);
+ * Example:
+ *
+ * this.item.user.name = 'Bob';
+ * this.notifyPath('item.user.name', this.item.user.name);
*
* @param {string} path Path that should be notified.
* @param {*} value Value of the specified path.
@@ -79,6 +81,15 @@
* based on a dirty check of whether the new value was already known.
*/
notifyPath: function(path, value, fromAbove) {
+ // Convert any array indicies to keys before notifying path
+ var info = {};
+ path = this.get(path, this, info);
+ // Notify change to key-based path
+ this._notifyPath(info.path, value, fromAbove);
+ },
+
+ // Note: this implemetation only accepts key-based array paths
+ _notifyPath: function(path, value, fromAbove) {
var old = this._propertySetter(path, value);
// manual dirty checking for now...
// NaN is always not equal to itself,
@@ -94,7 +105,7 @@
// is coming from above already (avoid wasted event dispatch)
if (!fromAbove) {
// TODO(sorvell): should only notify if notify: true?
- this._notifyPath(path, value);
+ this._notifyPathUp(path, value);
}
// console.groupEnd((this.localName || this.dataHost.id + '-' + this.dataHost.dataHost.index) + '#' + (this.id || this.index) + ' ' + path, value);
return true;
@@ -146,29 +157,56 @@
var array;
var last = parts[parts.length-1];
if (parts.length > 1) {
+ // Loop over path parts[0..n-2] and dereference
for (var i=0; i