| OLD | NEW |
| 1 'use strict'; | 1 'use strict'; |
| 2 | 2 |
| 3 Polymer({ | 3 Polymer({ |
| 4 is: 'app-route', | 4 is: 'app-route', |
| 5 | 5 |
| 6 properties: { | 6 properties: { |
| 7 /** | 7 /** |
| 8 * The URL component managed by this element. | 8 * The URL component managed by this element. |
| 9 */ | 9 */ |
| 10 route: { | 10 route: { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 '__routeQueryParamsChanged(route.__queryParams)', | 80 '__routeQueryParamsChanged(route.__queryParams)', |
| 81 '__tailQueryParamsChanged(tail.__queryParams)', | 81 '__tailQueryParamsChanged(tail.__queryParams)', |
| 82 '__queryParamsChanged(queryParams.*)' | 82 '__queryParamsChanged(queryParams.*)' |
| 83 ], | 83 ], |
| 84 | 84 |
| 85 created: function() { | 85 created: function() { |
| 86 this.linkPaths('route.__queryParams', 'tail.__queryParams'); | 86 this.linkPaths('route.__queryParams', 'tail.__queryParams'); |
| 87 this.linkPaths('tail.__queryParams', 'route.__queryParams'); | 87 this.linkPaths('tail.__queryParams', 'route.__queryParams'); |
| 88 }, | 88 }, |
| 89 | 89 |
| 90 // IE Object.assign polyfill | |
| 91 __assign: function(target, source) { | |
| 92 if (Object.assign) { | |
| 93 return Object.assign(target, source); | |
| 94 } | |
| 95 if (source != null) { | |
| 96 for (var key in source) { | |
| 97 target[key] = source[key]; | |
| 98 } | |
| 99 } | |
| 100 | |
| 101 return target; | |
| 102 }, | |
| 103 | |
| 104 /** | 90 /** |
| 105 * Deal with the query params object being assigned to wholesale. | 91 * Deal with the query params object being assigned to wholesale. |
| 106 * @export | 92 * @export |
| 107 */ | 93 */ |
| 108 __routeQueryParamsChanged: function(queryParams) { | 94 __routeQueryParamsChanged: function(queryParams) { |
| 109 if (queryParams && this.tail) { | 95 if (queryParams && this.tail) { |
| 110 this.set('tail.__queryParams', queryParams); | 96 this.set('tail.__queryParams', queryParams); |
| 111 | 97 |
| 112 if (!this.active || this._queryParamsUpdating) { | 98 if (!this.active || this._queryParamsUpdating) { |
| 113 return; | 99 return; |
| 114 } | 100 } |
| 115 | 101 |
| 102 // Copy queryParams and track whether there are any differences compared |
| 103 // to the existing query params. |
| 104 var copyOfQueryParams = {}; |
| 105 var anythingChanged = false; |
| 106 for (var key in queryParams) { |
| 107 copyOfQueryParams[key] = queryParams[key]; |
| 108 if (anythingChanged || |
| 109 !this.queryParams || |
| 110 queryParams[key] !== this.queryParams[key]) { |
| 111 anythingChanged = true; |
| 112 } |
| 113 } |
| 114 // Need to check whether any keys were deleted |
| 115 for (var key in this.queryParams) { |
| 116 if (anythingChanged || !(key in queryParams)) { |
| 117 anythingChanged = true; |
| 118 break; |
| 119 } |
| 120 } |
| 121 |
| 122 if (!anythingChanged) { |
| 123 return; |
| 124 } |
| 116 this._queryParamsUpdating = true; | 125 this._queryParamsUpdating = true; |
| 117 this.set('queryParams', this.__assign({}, queryParams)); | 126 this.set('queryParams', copyOfQueryParams); |
| 118 this._queryParamsUpdating = false; | 127 this._queryParamsUpdating = false; |
| 119 } | 128 } |
| 120 }, | 129 }, |
| 121 | 130 |
| 122 /** | 131 /** |
| 123 * @export | 132 * @export |
| 124 */ | 133 */ |
| 125 __tailQueryParamsChanged: function(queryParams) { | 134 __tailQueryParamsChanged: function(queryParams) { |
| 126 if (queryParams && this.route) { | 135 if (queryParams && this.route) { |
| 127 this.set('route.__queryParams', queryParams); | 136 this.set('route.__queryParams', queryParams); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 for (var property in setObj) { | 310 for (var property in setObj) { |
| 302 this._propertySetter(property, setObj[property]); | 311 this._propertySetter(property, setObj[property]); |
| 303 } | 312 } |
| 304 | 313 |
| 305 for (var property in setObj) { | 314 for (var property in setObj) { |
| 306 this._pathEffector(property, this[property]); | 315 this._pathEffector(property, this[property]); |
| 307 this._notifyPathUp(property, this[property]); | 316 this._notifyPathUp(property, this[property]); |
| 308 } | 317 } |
| 309 } | 318 } |
| 310 }); | 319 }); |
| OLD | NEW |