|
19 | 19 |
|
20 | 20 | var properties = {
|
21 | 21 | // set up property observers
|
| 22 | + /* |
22 | 23 | observeProperties: function() {
|
23 | 24 | // TODO(sjmiles):
|
24 | 25 | // we observe published properties so we can reflect them to attributes
|
|
48 | 49 | }
|
49 | 50 | }
|
50 | 51 | },
|
| 52 | + */ |
51 | 53 | _observe: function(name, cb) {
|
52 | 54 | log.observe && console.log(LOG_OBSERVE, this.localName, name);
|
53 | 55 | registerObserver(this, name,
|
|
81 | 83 | },
|
82 | 84 | unbindAllProperties: function() {
|
83 | 85 | unregisterObservers(this);
|
84 |
| - } |
| 86 | + if (this._propertyObserver) { |
| 87 | + this._propertyObserver.close(); |
| 88 | + } |
| 89 | + }, |
| 90 | + |
| 91 | + observeProperties: function() { |
| 92 | + var n$ = this._observeNames, pn$ = this._publishNames; |
| 93 | + if ((n$ && n$.length) || (pn$ && pn$.length)) { |
| 94 | + var self = this; |
| 95 | + var o = this._propertyObserver = new CompoundPathObserver(function( |
| 96 | + newValues, oldValues, changedBits) { |
| 97 | + self.notifyPropertyChanges(newValues, oldValues, changedBits); |
| 98 | + }, this, undefined, undefined); |
| 99 | + var p = this._propertyObserverNames = []; |
| 100 | + for (var i=0, l=n$.length, n; (i<l) && (n=n$[i]); i++) { |
| 101 | + p.push(n); |
| 102 | + o.addPath(this, n); |
| 103 | + } |
| 104 | + for (var i=0, l=pn$.length, n; (i<l) && (n=pn$[i]); i++) { |
| 105 | + if (!this.observe || (this.observe[n] === undefined)) { |
| 106 | + p.push(n); |
| 107 | + o.addPath(this, n); |
| 108 | + } |
| 109 | + } |
| 110 | + //console.log(p); |
| 111 | + o.start(); |
| 112 | + } |
| 113 | + }, |
| 114 | + |
| 115 | + notifyPropertyChanges: function(newValues, oldValues, changedBits) { |
| 116 | + for (var i=0, l=changedBits.length, n; i<l; i++) { |
| 117 | + if (changedBits[i]) { |
| 118 | + n = this._propertyObserverNames[i]; |
| 119 | + //console.log(n, this.publish[n], this.observe[n]); |
| 120 | + if (this.publish[n] !== undefined) { |
| 121 | + this.relectPropertyToAttribute(n); |
| 122 | + } |
| 123 | + if (this.observe[n]) { |
| 124 | + invoke.call(this, this.observe[n], [oldValues[i]]); |
| 125 | + } |
| 126 | + } |
| 127 | + } |
| 128 | + }, |
85 | 129 | };
|
86 | 130 |
|
87 | 131 | function invoke(method, args) {
|
|
135 | 179 | }
|
136 | 180 |
|
137 | 181 | function getElementObservers(element) {
|
| 182 | + //window.timer && timer.time('getElementObservers'); |
| 183 | + var b$ = element._propertyBindingObservers || |
| 184 | + (element._propertyBindingObservers = {}); |
| 185 | + /* |
138 | 186 | var b$ = observers.get(element);
|
139 | 187 | if (!b$) {
|
140 | 188 | observers.set(element, b$ = {});
|
141 | 189 | }
|
| 190 | + */ |
| 191 | + //window.timer && timer.timeEnd('getElementObservers'); |
142 | 192 | return b$;
|
143 | 193 | }
|
144 | 194 |
|
|
0 commit comments