OLD | NEW |
1 iron-meta | 1 iron-meta |
2 ========= | 2 ========= |
3 | 3 |
4 `iron-meta` is a generic element you can use for sharing information across the
DOM tree. | 4 `iron-meta` is a generic element you can use for sharing information across the
DOM tree. |
5 It uses [monostate pattern](http://c2.com/cgi/wiki?MonostatePattern) such that a
ny | 5 It uses [monostate pattern](http://c2.com/cgi/wiki?MonostatePattern) such that a
ny |
6 instance of iron-meta has access to the shared | 6 instance of iron-meta has access to the shared |
7 information. You can use `iron-meta` to share whatever you want (or create an ex
tension | 7 information. You can use `iron-meta` to share whatever you want (or create an ex
tension |
8 [like x-meta] for enhancements). | 8 [like x-meta] for enhancements). |
9 | 9 |
10 The `iron-meta` instances containing your actual data can be loaded in an import
, | 10 The `iron-meta` instances containing your actual data can be loaded in an import
, |
11 or constructed in any way you see fit. The only requirement is that you create t
hem | 11 or constructed in any way you see fit. The only requirement is that you create t
hem |
12 before you try to access them. | 12 before you try to access them. |
13 | 13 |
14 Examples: | 14 Examples: |
15 | 15 |
16 If I create an instance like this: | 16 If I create an instance like this: |
17 | 17 |
18 ```html | 18 ```html |
19 <iron-meta key="info" keyUrl="foo/bar"></iron-meta> | 19 <iron-meta key="info" value="foo/bar"></iron-meta> |
20 ``` | 20 ``` |
21 | 21 |
22 Note that keyUrl="foo/bar" is the metadata I've defined. I could define more | 22 Note that value="foo/bar" is the metadata I've defined. I could define more |
23 attributes or use child nodes to define additional metadata. | 23 attributes or use child nodes to define additional metadata. |
24 | 24 |
25 Now I can access that element (and it's metadata) from any iron-meta instance | 25 Now I can access that element (and it's metadata) from any iron-meta instance |
26 via the byKey method, e.g. | 26 via the byKey method, e.g. |
27 | 27 |
28 ```javascript | 28 ```javascript |
29 meta.byKey('info').getAttribute('keyUrl'). | 29 meta.byKey('info').getAttribute('value'); |
30 ``` | 30 ``` |
31 | 31 |
32 Pure imperative form would be like: | 32 Pure imperative form would be like: |
33 | 33 |
34 ```javascript | 34 ```javascript |
35 document.createElement('iron-meta').byKey('info').getAttribute('keyUrl'); | 35 document.createElement('iron-meta').byKey('info').getAttribute('value'); |
36 ``` | 36 ``` |
37 | 37 |
38 Or, in a Polymer element, you can include a meta in your template: | 38 Or, in a Polymer element, you can include a meta in your template: |
39 | 39 |
40 ```html | 40 ```html |
41 <iron-meta id="meta"></iron-meta> | 41 <iron-meta id="meta"></iron-meta> |
42 ``` | 42 ``` |
43 | 43 |
44 ```javascript | 44 ```javascript |
45 this.$.meta.byKey('info').getAttribute('keyUrl'); | 45 this.$.meta.byKey('info').getAttribute('value'); |
46 ``` | 46 ``` |
OLD | NEW |