OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 2 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
6 Code distributed by Google as part of the polymer project is also | 6 Code distributed by Google as part of the polymer project is also |
7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
8 --> | 8 --> |
9 <link rel="import" href="../polymer/polymer.html"> | 9 <link rel="import" href="../polymer/polymer.html"> |
10 <link rel="import" href="../observe-js/observe-js.html"> | |
11 | 10 |
12 <link rel="import" href="routing.html"> | 11 <link rel="import" href="routing.html"> |
13 <link rel="import" href="more-route-context-aware.html"> | 12 <link rel="import" href="more-route-context-aware.html"> |
14 | 13 |
15 <script> | 14 <script> |
16 | 15 |
17 Polymer({ | 16 Polymer({ |
18 | 17 |
19 is: 'more-route', | 18 is: 'more-route', |
20 | 19 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 if (parent.nodeType === Node.ELEMENT_NODE) { | 149 if (parent.nodeType === Node.ELEMENT_NODE) { |
151 parent.moreRouteContext = this.route; | 150 parent.moreRouteContext = this.route; |
152 } else { | 151 } else { |
153 console.warn('Unable to determine parent element for', this, '- not se
tting a context'); | 152 console.warn('Unable to determine parent element for', this, '- not se
tting a context'); |
154 } | 153 } |
155 } | 154 } |
156 }, | 155 }, |
157 | 156 |
158 _observeRoute: function() { | 157 _observeRoute: function() { |
159 // TODO(nevir) https://github.com/Polymore/more-routing/issues/24 | 158 // TODO(nevir) https://github.com/Polymore/more-routing/issues/24 |
160 if (this._routeObserver) this._routeObserver.close(); | 159 if (this._routeListener) { |
161 if (this._paramObserver) this._paramObserver.close(); | 160 this._routeListener.close(); |
| 161 this._routeListener = null; |
| 162 } |
| 163 if (this._paramListener) { |
| 164 this._paramListener.close(); |
| 165 this._paramListener = null; |
| 166 } |
162 if (!this.route) return; | 167 if (!this.route) return; |
163 | 168 |
164 this._routeObserver = new CompoundObserver(); | 169 this._routeListener = this.route.__subscribe(function() { |
165 this._routeObserver.addPath(this.route, 'active'); | 170 this._setActive(this.route && this.route.active); |
166 this._routeObserver.open(function() { | |
167 this._setActive(this.route.active); | |
168 }.bind(this)); | 171 }.bind(this)); |
169 | 172 |
170 this._paramObserver = new ObjectObserver(this.route.params); | 173 this._paramListener = this.route.params.__subscribe(function(key, value) { |
171 this._paramObserver.open(function(added, removed, changed, getOldValue) { | 174 // https://github.com/Polymer/polymer/issues/1505 |
172 var keys = Object.keys(added).concat(Object.keys(removed)).concat(Object
.keys(changed)); | 175 this.notifyPath('params.' + key, value); |
173 keys.forEach(function(key) { | |
174 this.notifyPath('params.' + key, this.params[key]); | |
175 }.bind(this)); | |
176 }.bind(this)); | 176 }.bind(this)); |
177 }, | 177 }, |
178 | 178 |
179 urlFor: function(params) { | 179 urlFor: function(params) { |
180 return this.route.urlFor(params); | 180 return this.route.urlFor(params); |
181 }, | 181 }, |
182 | 182 |
183 navigateTo: function(params) { | 183 navigateTo: function(params) { |
184 return this.route.navigateTo(params); | 184 return this.route.navigateTo(params); |
185 }, | 185 }, |
186 | 186 |
187 isCurrentUrl: function(params) { | 187 isCurrentUrl: function(params) { |
188 return this.route.isCurrentUrl(params); | 188 return this.route.isCurrentUrl(params); |
189 }, | 189 }, |
190 | 190 |
191 }); | 191 }); |
192 | 192 |
193 </script> | 193 </script> |
OLD | NEW |