From bb38dff767bf2f75918ccdfe6c01e760bcec9544 Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Tue, 1 Oct 2013 14:52:34 -0700 Subject: [PATCH] observe properties via compound path observer. --- src/instance/properties.js | 52 +++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/src/instance/properties.js b/src/instance/properties.js index 4223d813ba..d5a19f4d8c 100644 --- a/src/instance/properties.js +++ b/src/instance/properties.js @@ -19,6 +19,7 @@ var properties = { // set up property observers + /* observeProperties: function() { // TODO(sjmiles): // we observe published properties so we can reflect them to attributes @@ -48,6 +49,7 @@ } } }, + */ _observe: function(name, cb) { log.observe && console.log(LOG_OBSERVE, this.localName, name); registerObserver(this, name, @@ -81,7 +83,49 @@ }, unbindAllProperties: function() { unregisterObservers(this); - } + if (this._propertyObserver) { + this._propertyObserver.close(); + } + }, + + observeProperties: function() { + var n$ = this._observeNames, pn$ = this._publishNames; + if ((n$ && n$.length) || (pn$ && pn$.length)) { + var self = this; + var o = this._propertyObserver = new CompoundPathObserver(function( + newValues, oldValues, changedBits) { + self.notifyPropertyChanges(newValues, oldValues, changedBits); + }, this, undefined, undefined); + var p = this._propertyObserverNames = []; + for (var i=0, l=n$.length, n; (i