| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 @license | |
| 3 Copyright (c) 2016 The Polymer Project Authors. All rights reserved. | |
| 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | |
| 7 Code distributed by Google as part of the polymer project is also | |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | |
| 9 --><html><head><link rel="import" href="../polymer/polymer.html"> | |
| 10 <link rel="import" href="./app-route-converter-behavior.html"> | |
| 11 | |
| 12 <!-- | |
| 13 `app-route-converter` provides a means to convert a path and query | |
| 14 parameters into a route object and vice versa. This produced route object | |
| 15 is to be fed into route-consuming elements such as `app-route`. | |
| 16 | |
| 17 > n.b. This element is intended to be a primitive of the routing system and for | |
| 18 creating bespoke routing solutions from scratch. To simply include routing in | |
| 19 an app, please refer to [app-location](https://github.com/PolymerElements/app-ro
ute/blob/master/app-location.html) | |
| 20 and [app-route](https://github.com/PolymerElements/app-route/blob/master/app-rou
te.html). | |
| 21 | |
| 22 An example of a route object that describes | |
| 23 `https://elements.polymer-project.org/elements/app-route-converter?foo=bar&baz=q
ux` | |
| 24 and should be passed to other `app-route` elements: | |
| 25 | |
| 26 { | |
| 27 prefix: '', | |
| 28 path: '/elements/app-route-converter', | |
| 29 __queryParams: { | |
| 30 foo: 'bar', | |
| 31 baz: 'qux' | |
| 32 } | |
| 33 } | |
| 34 | |
| 35 `__queryParams` is private to discourage directly data-binding to it. This is so | |
| 36 that routing elements like `app-route` can intermediate changes to the query | |
| 37 params and choose whether to propagate them upstream or not. `app-route` for | |
| 38 example will not propagate changes to its `queryParams` property if it is not | |
| 39 currently active. A public queryParams object will also be produced in which you | |
| 40 should perform data-binding operations. | |
| 41 | |
| 42 Example Usage: | |
| 43 | |
| 44 <iron-location path="{{path}}" query="{{query}}"></iron-location> | |
| 45 <iron-query-params | |
| 46 params-string="{{query}}" | |
| 47 params-object="{{queryParams}}"> | |
| 48 </iron-query-params> | |
| 49 <app-route-converter | |
| 50 path="{{path}}" | |
| 51 query-params="{{queryParams}}" | |
| 52 route="{{route}}"> | |
| 53 </app-route-converter> | |
| 54 <app-route route='{{route}}' pattern='/:page' data='{{data}}'> | |
| 55 </app-route> | |
| 56 | |
| 57 This is a simplified implementation of the `app-location` element. Here the | |
| 58 `iron-location` produces a path and a query, the `iron-query-params` consumes | |
| 59 the query and produces a queryParams object, and the `app-route-converter` | |
| 60 consumes the path and the query params and converts it into a route which is in | |
| 61 turn is consumed by the `app-route`. | |
| 62 | |
| 63 @element app-route-converter | |
| 64 @demo demo/index.html | |
| 65 --> | |
| 66 | |
| 67 </head><body><script src="app-route-converter-extracted.js"></script></body></ht
ml> | |
| OLD | NEW |