|
21 | 21 | var properties = { |
22 | 22 | // set up property observers |
23 | 23 | observeProperties: function() { |
24 | | - // TODO(sjmiles): |
| 24 | + // TODO(sjmiles): |
25 | 25 | // we observe published properties so we can reflect them to attributes |
26 | 26 | // ~100% of our team's applications would work without this: |
27 | 27 | // perhaps we can make it optional somehow |
28 | | - //console.group('[%s]:observeProperties', this.localName); |
29 | | - // add observers as explicitly requested |
30 | | - for (var n in this.observe) { |
31 | | - //console.log('observable:', n); |
32 | | - var m = this.observe[n]; |
33 | | - //if (this.publish && this.publish[n]) { |
34 | | - //this.observeBoth(n, m); |
35 | | - //} else { |
36 | | - this.observeProperty(n, m); |
37 | | - //} |
| 28 | + // |
| 29 | + // add user's observers |
| 30 | + var n$ = this._observeNames; |
| 31 | + if (n$) { |
| 32 | + for (var i=0, l=n$.length, n; (i<l) && (n=n$[i]); i++) { |
| 33 | + var m = this.observe[n]; |
| 34 | + if (this.publish && (this.publish[n] !== undefined)) { |
| 35 | + this.observeBoth(n, m); |
| 36 | + } else { |
| 37 | + this.observeProperty(n, m); |
| 38 | + } |
| 39 | + } |
38 | 40 | } |
39 | | - // add observers for left-over published properties |
40 | | - for (var n in this.publish) { |
41 | | - //if (this.observe && !this.observe[n]) { |
42 | | - //console.log('attr-prop:', n); |
43 | | - this.observeAttributeProperty(n); |
44 | | - //} |
| 41 | + // add observers for published properties |
| 42 | + var n$ = this._publishNames; |
| 43 | + if (n$) { |
| 44 | + for (var i=0, l=n$.length, n; (i<l) && (n=n$[i]); i++) { |
| 45 | + if (!this.observe || (this.observe[n] === undefined)) { |
| 46 | + this.observeAttributeProperty(n, this.publish[n]); |
| 47 | + } |
| 48 | + } |
45 | 49 | } |
46 | | - //console.groupEnd(); |
47 | 50 | }, |
48 | 51 | _observe: function(name, cb) { |
49 | 52 | log.watch && console.log(LOG_OBSERVE, this.localName, name); |
|
62 | 65 | invoke.call(self, methodName, [old]); |
63 | 66 | }); |
64 | 67 | }, |
65 | | - /* |
66 | 68 | observeBoth: function(name, methodName) { |
67 | 69 | var self = this; |
68 | 70 | this._observe(name, function(value, old) { |
69 | 71 | self.relectPropertyToAttribute(name); |
70 | 72 | invoke.call(self, methodName, [old]); |
71 | 73 | }); |
72 | 74 | }, |
73 | | - */ |
74 | 75 | bindProperty: function(property, model, path) { |
75 | 76 | // apply Polymer two-way reference binding |
76 | 77 | return bindProperties(this, property, model, path); |
|
0 commit comments