From a2376b6e953f139d52d2b6caa68dd6700f956881 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Mon, 2 Nov 2015 17:24:44 -0800 Subject: [PATCH] provides support for memoizing pathFn on effect; only process effects/listeners if they exist. --- src/lib/bind/accessors.html | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/lib/bind/accessors.html b/src/lib/bind/accessors.html index 352e8e6d02..1b854b982e 100644 --- a/src/lib/bind/accessors.html +++ b/src/lib/bind/accessors.html @@ -14,10 +14,7 @@ _dataEventCache: {}, // for prototypes (usually) - prepareModel: function(model) { - model._propertyEffects = {}; - model._bindListeners = []; Polymer.Base.mixin(model, this._modelApi); }, @@ -106,6 +103,9 @@ // a prepared model can acquire effects ensurePropertyEffects: function(model, property) { + if (!model._propertyEffects) { + model._propertyEffects = {}; + } var fx = model._propertyEffects[property]; if (!fx) { fx = model._propertyEffects[property] = []; @@ -115,11 +115,13 @@ addPropertyEffect: function(model, property, kind, effect) { var fx = this.ensurePropertyEffects(model, property); - fx.push({ + var propEffect = { kind: kind, effect: effect, fn: Polymer.Bind['_' + kind + 'Effect'] - }); + }; + fx.push(propEffect); + return propEffect; }, createBindings: function(model) { @@ -193,6 +195,9 @@ }, _addAnnotatedListener: function(model, index, property, path, event) { + if (!model._bindListeners) { + model._bindListeners = []; + } var fn = this._notedListenerFactory(property, path, this._isStructured(path)); var eventName = event ||