OLD | NEW |
| (Empty) |
1 | |
2 | |
3 MoreRouting.ContextAware = { | |
4 | |
5 /** @override */ | |
6 ready: function() { | |
7 this._makeRoutingReady(); | |
8 }, | |
9 | |
10 /** | |
11 * Calls `routingReady`, and ensures that it is called in a top-down manner. | |
12 * | |
13 * We need to be sure that parent nodes have `routingReady` triggered before | |
14 * their children so that they can properly configure nested routes. | |
15 * | |
16 * Unfortunately, `ready` is sometimes bottom-up, sometimes top-down. | |
17 * Ideally, this wouldn't be necessary. | |
18 * | |
19 * @see https://github.com/Polymer/polymer/pull/1448 | |
20 */ | |
21 _makeRoutingReady: function() { | |
22 if (this.routingIsReady) return; | |
23 | |
24 var node = this; | |
25 while (node = Polymer.dom(node).parentNode) { | |
26 if (typeof node._makeRoutingReady === 'function') break; | |
27 } | |
28 if (node) node._makeRoutingReady(); | |
29 | |
30 this.parentRoute = this._findParentRoute(); | |
31 this.routingIsReady = true; | |
32 if (typeof this.routingReady === 'function') this.routingReady(); | |
33 }, | |
34 | |
35 _findParentRoute: function() { | |
36 var node = this; | |
37 while (node) { | |
38 node = Polymer.dom(node).parentNode; | |
39 if (node && node.nodeType !== Node.ELEMENT_NODE) { | |
40 node = node.host; | |
41 } | |
42 | |
43 var route = node && node.moreRouteContext; | |
44 if (route instanceof MoreRouting.Route) { | |
45 return route; | |
46 } | |
47 } | |
48 return null; | |
49 }, | |
50 | |
51 }; | |
52 | |
OLD | NEW |