| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('settings', function() { | 5 cr.define('settings', function() { |
| 6 /** | 6 /** |
| 7 * Class for navigable routes. May only be instantiated within this file. | 7 * Class for navigable routes. May only be instantiated within this file. |
| 8 * @constructor | 8 * @constructor |
| 9 * @param {string} path | 9 * @param {string} path |
| 10 * @private | 10 * @private |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 var params = opt_dynamicParameters || new URLSearchParams(); | 327 var params = opt_dynamicParameters || new URLSearchParams(); |
| 328 | 328 |
| 329 var url = route.path; | 329 var url = route.path; |
| 330 if (opt_dynamicParameters) { | 330 if (opt_dynamicParameters) { |
| 331 var queryString = opt_dynamicParameters.toString(); | 331 var queryString = opt_dynamicParameters.toString(); |
| 332 if (queryString) | 332 if (queryString) |
| 333 url += '?' + queryString; | 333 url += '?' + queryString; |
| 334 } | 334 } |
| 335 | 335 |
| 336 // History serializes the state, so we don't push the actual route object. | 336 // History serializes the state, so we don't push the actual route object. |
| 337 var previousRoutePath = currentRoute_.path; | 337 window.history.pushState(currentRoute_.path, '', url); |
| 338 setCurrentRoute(route, params); | 338 setCurrentRoute(route, params); |
| 339 window.history.pushState(previousRoutePath, '', url); | |
| 340 }; | 339 }; |
| 341 | 340 |
| 342 window.addEventListener('popstate', function(event) { | 341 window.addEventListener('popstate', function(event) { |
| 343 // On pop state, do not push the state onto the window.history again. | 342 // On pop state, do not push the state onto the window.history again. |
| 344 setCurrentRoute(getRouteForPath(window.location.pathname) || Route.BASIC, | 343 setCurrentRoute(getRouteForPath(window.location.pathname) || Route.BASIC, |
| 345 new URLSearchParams(window.location.search)); | 344 new URLSearchParams(window.location.search)); |
| 346 }); | 345 }); |
| 347 | 346 |
| 348 return { | 347 return { |
| 349 Route: Route, | 348 Route: Route, |
| 350 RouteObserverBehavior: RouteObserverBehavior, | 349 RouteObserverBehavior: RouteObserverBehavior, |
| 351 getRouteForPath: getRouteForPath, | 350 getRouteForPath: getRouteForPath, |
| 352 initializeRouteFromUrl: initializeRouteFromUrl, | 351 initializeRouteFromUrl: initializeRouteFromUrl, |
| 353 getCurrentRoute: getCurrentRoute, | 352 getCurrentRoute: getCurrentRoute, |
| 354 getQueryParameters: getQueryParameters, | 353 getQueryParameters: getQueryParameters, |
| 355 navigateTo: navigateTo, | 354 navigateTo: navigateTo, |
| 356 }; | 355 }; |
| 357 }); | 356 }); |
| OLD | NEW |