Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(726)

Side by Side Diff: third_party/polymer/v1_0/components-chromium/app-route/app-route-converter-behavior-extracted.js

Issue 1984963002: Roll Polymer elements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 'use strict'; 1 'use strict';
2 2
3 Polymer({ 3 /**
4 is: 'carbon-route-converter', 4 * Provides bidirectional mapping between `path` and `queryParams` and a
5 5 * app-route compatible `route` object.
6 *
7 * For more information, see the docs for `app-route-converter`.
8 *
9 * @polymerBehavior
10 */
11 Polymer.AppRouteConverterBehavior = {
6 properties: { 12 properties: {
7 /** 13 /**
8 * A model representing the deserialized path through the route tree, as 14 * A model representing the deserialized path through the route tree, as
9 * well as the current queryParams. 15 * well as the current queryParams.
10 * 16 *
11 * A route object is the kernel of the routing system. It is intended to 17 * A route object is the kernel of the routing system. It is intended to
12 * be fed into consuming elements such as `carbon-route`. 18 * be fed into consuming elements such as `app-route`.
13 * 19 *
14 * @type {?Object} 20 * @type {?Object}
15 */ 21 */
16 route: { 22 route: {
17 type: Object, 23 type: Object,
18 value: null,
19 notify: true 24 notify: true
20 }, 25 },
21 26
22 /** 27 /**
23 * A set of key/value pairs that are universally accessible to branches of 28 * A set of key/value pairs that are universally accessible to branches of
24 * the route tree. 29 * the route tree.
25 * 30 *
26 * @type {?Object} 31 * @type {?Object}
27 */ 32 */
28 queryParams: { 33 queryParams: {
29 type: Object, 34 type: Object,
30 value: null,
31 notify: true 35 notify: true
32 }, 36 },
33 37
34 /** 38 /**
35 * The serialized path through the route tree. This corresponds to the 39 * The serialized path through the route tree. This corresponds to the
36 * `window.location.pathname` value, and will update to reflect changes 40 * `window.location.pathname` value, and will update to reflect changes
37 * to that value. 41 * to that value.
38 */ 42 */
39 path: { 43 path: {
40 type: String, 44 type: String,
41 notify: true, 45 notify: true,
42 value: ''
43 } 46 }
44 }, 47 },
45 48
46 observers: [ 49 observers: [
47 '_locationChanged(path, queryParams)', 50 '_locationChanged(path, queryParams)',
48 '_routeChanged(route.prefix, route.path)', 51 '_routeChanged(route.prefix, route.path)',
49 '_routeQueryParamsChanged(route.__queryParams)' 52 '_routeQueryParamsChanged(route.__queryParams)'
50 ], 53 ],
51 54
52 created: function() { 55 created: function() {
53 this.linkPaths('route.__queryParams', 'queryParams'); 56 this.linkPaths('route.__queryParams', 'queryParams');
54 this.linkPaths('queryParams', 'route.__queryParams'); 57 this.linkPaths('queryParams', 'route.__queryParams');
55 }, 58 },
56 59
57 /** 60 /**
58 * Handler called when the path or queryParams change. 61 * Handler called when the path or queryParams change.
59 *
60 * @param {!string} path The serialized path through the route tree.
61 * @param {Object} queryParams A set of key/value pairs that are
62 * universally accessible to branches of the route tree.
63 */ 62 */
64 _locationChanged: function(path, queryParams) { 63 _locationChanged: function() {
64 if (this.route &&
65 this.route.path === this.path &&
66 this.queryParams === this.route.__queryParams) {
67 return;
68 }
65 this.route = { 69 this.route = {
66 prefix: '', 70 prefix: '',
67 path: path, 71 path: this.path,
68 __queryParams: queryParams 72 __queryParams: this.queryParams
69 }; 73 };
70 }, 74 },
71 75
72 /** 76 /**
73 * Handler called when the route prefix and route path change. 77 * Handler called when the route prefix and route path change.
74 *
75 * @param {!string} prefix The fragment of the pathname that precedes the
76 * path.
77 * @param {!string} path The serialized path through the route tree.
78 */ 78 */
79 _routeChanged: function(prefix, path) { 79 _routeChanged: function() {
80 if (!this.route) { 80 if (!this.route) {
81 return; 81 return;
82 } 82 }
83 83
84 this.path = prefix + path; 84 this.path = this.route.prefix + this.route.path;
85 }, 85 },
86 86
87 /** 87 /**
88 * Handler called when the route queryParams change. 88 * Handler called when the route queryParams change.
89 * 89 *
90 * @param {Object} queryParams A set of key/value pairs that are 90 * @param {Object} queryParams A set of key/value pairs that are
91 * universally accessible to branches of the route tree. 91 * universally accessible to branches of the route tree.
92 */ 92 */
93 _routeQueryParamsChanged: function(queryParams) { 93 _routeQueryParamsChanged: function(queryParams) {
94 if (!this.route) { 94 if (!this.route) {
95 return; 95 return;
96 } 96 }
97 this.queryParams = queryParams; 97 this.queryParams = queryParams;
98 } 98 }
99 }); 99 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698