Add ICU message format support
[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.
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;
24       var node = this;
25       while (node = Polymer.dom(node).parentNode) {
26         if (typeof node._makeRoutingReady === 'function') break;
27       }
28       if (node) node._makeRoutingReady();
30       this.parentRoute = this._findParentRoute();
31       this.routingIsReady = true;
32       if (typeof this.routingReady === 'function') this.routingReady();
33     },
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         }
43         var route = node && node.moreRouteContext;
44         if (route instanceof MoreRouting.Route) {
45           return route;
46         }
47       }
48       return null;
49     },
51   };