OLD | NEW |
1 | 1 |
2 | 2 |
3 Polymer({ | 3 Polymer({ |
4 | 4 |
5 is: 'more-route', | 5 is: 'more-route', |
6 | 6 |
7 behaviors: [ | 7 behaviors: [ |
8 MoreRouting.ContextAware, | 8 MoreRouting.ContextAware, |
9 ], | 9 ], |
10 | 10 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 if (parent.nodeType === Node.ELEMENT_NODE) { | 136 if (parent.nodeType === Node.ELEMENT_NODE) { |
137 parent.moreRouteContext = this.route; | 137 parent.moreRouteContext = this.route; |
138 } else { | 138 } else { |
139 console.warn('Unable to determine parent element for', this, '- not se
tting a context'); | 139 console.warn('Unable to determine parent element for', this, '- not se
tting a context'); |
140 } | 140 } |
141 } | 141 } |
142 }, | 142 }, |
143 | 143 |
144 _observeRoute: function() { | 144 _observeRoute: function() { |
145 // TODO(nevir) https://github.com/Polymore/more-routing/issues/24 | 145 // TODO(nevir) https://github.com/Polymore/more-routing/issues/24 |
146 if (this._routeObserver) this._routeObserver.close(); | 146 if (this._routeListener) { |
147 if (this._paramObserver) this._paramObserver.close(); | 147 this._routeListener.close(); |
| 148 this._routeListener = null; |
| 149 } |
| 150 if (this._paramListener) { |
| 151 this._paramListener.close(); |
| 152 this._paramListener = null; |
| 153 } |
148 if (!this.route) return; | 154 if (!this.route) return; |
149 | 155 |
150 this._routeObserver = new CompoundObserver(); | 156 this._routeListener = this.route.__subscribe(function() { |
151 this._routeObserver.addPath(this.route, 'active'); | 157 this._setActive(this.route && this.route.active); |
152 this._routeObserver.open(function() { | |
153 this._setActive(this.route.active); | |
154 }.bind(this)); | 158 }.bind(this)); |
155 | 159 |
156 this._paramObserver = new ObjectObserver(this.route.params); | 160 this._paramListener = this.route.params.__subscribe(function(key, value) { |
157 this._paramObserver.open(function(added, removed, changed, getOldValue) { | 161 // https://github.com/Polymer/polymer/issues/1505 |
158 var keys = Object.keys(added).concat(Object.keys(removed)).concat(Object
.keys(changed)); | 162 this.notifyPath('params.' + key, value); |
159 keys.forEach(function(key) { | |
160 this.notifyPath('params.' + key, this.params[key]); | |
161 }.bind(this)); | |
162 }.bind(this)); | 163 }.bind(this)); |
163 }, | 164 }, |
164 | 165 |
165 urlFor: function(params) { | 166 urlFor: function(params) { |
166 return this.route.urlFor(params); | 167 return this.route.urlFor(params); |
167 }, | 168 }, |
168 | 169 |
169 navigateTo: function(params) { | 170 navigateTo: function(params) { |
170 return this.route.navigateTo(params); | 171 return this.route.navigateTo(params); |
171 }, | 172 }, |
172 | 173 |
173 isCurrentUrl: function(params) { | 174 isCurrentUrl: function(params) { |
174 return this.route.isCurrentUrl(params); | 175 return this.route.isCurrentUrl(params); |
175 }, | 176 }, |
176 | 177 |
177 }); | 178 }); |
178 | 179 |
OLD | NEW |