ApplicationImpl cleanup, part 1:
[chromium-blink-merge.git] / third_party / polymer / v1_0 / components-chromium / more-routing / more-route-context-aware-extracted.js
blob38377c156ccf299df0b55114807efa16ebedce67
3 MoreRouting.ContextAware = {
5 /** @override */
6 ready: function() {
7 this._makeRoutingReady();
8 },
10 /**
11 * Calls `routingReady`, and ensures that it is called in a top-down manner.
13 * We need to be sure that parent nodes have `routingReady` triggered before
14 * their children so that they can properly configure nested routes.
16 * Unfortunately, `ready` is sometimes bottom-up, sometimes top-down.
17 * Ideally, this wouldn't be necessary.
19 * @see https://github.com/Polymer/polymer/pull/1448
21 _makeRoutingReady: function() {
22 if (this.routingIsReady) return;
24 var node = this;
25 while (node = Polymer.dom(node).parentNode) {
26 if (typeof node._makeRoutingReady === 'function') break;
28 if (node) node._makeRoutingReady();
30 this.parentRoute = this._findParentRoute();
31 this.routingIsReady = true;
32 if (typeof this.routingReady === 'function') this.routingReady();
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;
43 var route = node && node.moreRouteContext;
44 if (route instanceof MoreRouting.Route) {
45 return route;
48 return null;