diff --git a/src/lib/bind/accessors.html b/src/lib/bind/accessors.html index 335634b89f..7c8b64daea 100644 --- a/src/lib/bind/accessors.html +++ b/src/lib/bind/accessors.html @@ -272,20 +272,33 @@ setupBindListeners: function(inst) { var b$ = inst._bindListeners; for (var i=0, l=b$.length, info; (i.on.-changed: = e.detail.value - //console.log('[_setupBindListener]: [%s][%s] listening for [%s][%s-changed]', this.localName, info.path, info.id || info.index, info.property); - // - // TODO(sorvell): fix templatizer to support this before uncommenting - // Optimization: only add bind listeners if the bound property is notifying... + // TODO: Optimization: only add bind listeners if the bound property + // is notifying... var node = inst._nodes[info.index]; - //var p = node._propertyInfo && node._propertyInfo[info.property]; - //if (node._prepParentProperties || !node._propertyInfo || (p && p.notify)) { - this._addNotifyListener(node, inst, info.event, info.changedFn); - //} + // Add DOM Event listener + this._addNotifyListener(node, inst, info.event, info.changedFn); + // For path notifications add a property effect + if (node.addPropertyEffect) { + this._addNotifyEffect(node, inst, info.property, info.changedFn); + } } }, + _addNotifyEffect: function(node, instance, property, fn) { + node.addPropertyEffect(property, function(path, value, old, fromAbove) { + if (!fromAbove && path.indexOf('.') !== -1) { + var ev = { + target: this, + detail: { + path: path, + value: value + } + }; + instance._notifyListener(fn, ev); + } + }); + }, + // TODO(sorvell): note, adding these synchronously may impact performance, // measure and consider if we can defer until after first paint in some cases at least. _addNotifyListener: function(element, context, event, changedFn) { diff --git a/src/lib/template/templatizer.html b/src/lib/template/templatizer.html index 9aea9bd52a..25848f4b80 100644 --- a/src/lib/template/templatizer.html +++ b/src/lib/template/templatizer.html @@ -233,7 +233,7 @@ // Create accessors for each parent prop that forward the property to // template instances through abstract _forwardParentProp/Path API // that should be implemented by Templatizer users. - var propertyEffects = this.mixin({}, this._propertyEffects); + var propertyEffects = {}; var propertyInfo = this.mixin({}, this._propertyInfo); var prefixedParentProps = {}; for (prop in parentProps) { @@ -251,6 +251,15 @@ effect: {event: Polymer.CaseMap.camelToDashCase(parentProp) + '-changed'} }]; + if (template !== this) { + effects.push({ + kind: 'function', + effect: this._createNotifyUpListener(prop), + fn: Polymer.Bind._functionEffect, + pathFn: this._functionPathEffect, + customNotifyUp: true + }); + } propertyEffects[parentProp] = effects; propertyInfo[parentProp] = {}; prefixedParentProps[parentProp] = true; @@ -283,6 +292,33 @@ } }, + _createNotifyUpListener: function(prop) { + // We simulate something like the following upwards annotation: + // + // <---| + // | + //