| OLD | NEW |
| (Empty) | |
| 1 'use strict'; |
| 2 |
| 3 Polymer({ |
| 4 is: 'carbon-location', |
| 5 |
| 6 properties: { |
| 7 /** |
| 8 * A model representing the deserialized path through the route tree, as |
| 9 * well as the current queryParams. |
| 10 */ |
| 11 route: { |
| 12 type: Object, |
| 13 notify: true |
| 14 }, |
| 15 |
| 16 /** |
| 17 * In many scenarios, it is convenient to treat the `hash` as a stand-in |
| 18 * alternative to the `path`. For example, if deploying an app to a stat
ic |
| 19 * web server (e.g., Github Pages) - where one does not have control ove
r |
| 20 * server-side routing - it is usually a better experience to use the ha
sh |
| 21 * to represent paths through one's app. |
| 22 * |
| 23 * When this property is set to true, the `hash` will be used in place o
f |
| 24 |
| 25 * the `path` for generating a `route`. |
| 26 */ |
| 27 useHashAsPath: { |
| 28 type: Boolean, |
| 29 value: false |
| 30 }, |
| 31 |
| 32 /** |
| 33 * A regexp that defines the set of URLs that should be considered part |
| 34 * of this web app. |
| 35 * |
| 36 * Clicking on a link that matches this regex won't result in a full pag
e |
| 37 * navigation, but will instead just update the URL state in place. |
| 38 * |
| 39 * This regexp is given everything after the origin in an absolute |
| 40 * URL. So to match just URLs that start with /search/ do: |
| 41 * url-space-regex="^/search/" |
| 42 * |
| 43 * @type {string|RegExp} |
| 44 */ |
| 45 urlSpaceRegex: { |
| 46 type: String, |
| 47 notify: true |
| 48 }, |
| 49 |
| 50 /** |
| 51 * A set of key/value pairs that are universally accessible to branches |
| 52 * of the route tree. |
| 53 */ |
| 54 __queryParams: { |
| 55 type: Object |
| 56 }, |
| 57 |
| 58 /** |
| 59 * The pathname component of the current URL. |
| 60 */ |
| 61 __path: { |
| 62 type: String |
| 63 }, |
| 64 |
| 65 /** |
| 66 * The query string portion of the current URL. |
| 67 */ |
| 68 __query: { |
| 69 type: String |
| 70 }, |
| 71 |
| 72 /** |
| 73 * The hash portion of the current URL. |
| 74 */ |
| 75 __hash: { |
| 76 type: String |
| 77 } |
| 78 }, |
| 79 |
| 80 __computeRoutePath: function(path, hash, useHashAsPath) { |
| 81 return useHashAsPath ? hash : path; |
| 82 }, |
| 83 |
| 84 __onPathChanged: function(event) { |
| 85 var path = event.detail.value; |
| 86 |
| 87 if (this.useHashAsPath) { |
| 88 this.__hash = path; |
| 89 } else { |
| 90 this.__path = path; |
| 91 } |
| 92 } |
| 93 }); |
| OLD | NEW |