OLD | NEW |
| (Empty) |
1 iron-meta | |
2 ========= | |
3 | |
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 | |
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 | |
8 [like x-meta] for enhancements). | |
9 | |
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 | |
12 before you try to access them. | |
13 | |
14 Examples: | |
15 | |
16 If I create an instance like this: | |
17 | |
18 ```html | |
19 <iron-meta key="info" value="foo/bar"></iron-meta> | |
20 ``` | |
21 | |
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. | |
24 | |
25 Now I can access that element (and it's metadata) from any iron-meta instance | |
26 via the byKey method, e.g. | |
27 | |
28 ```javascript | |
29 meta.byKey('info').getAttribute('value'); | |
30 ``` | |
31 | |
32 Pure imperative form would be like: | |
33 | |
34 ```javascript | |
35 document.createElement('iron-meta').byKey('info').getAttribute('value'); | |
36 ``` | |
37 | |
38 Or, in a Polymer element, you can include a meta in your template: | |
39 | |
40 ```html | |
41 <iron-meta id="meta"></iron-meta> | |
42 ``` | |
43 | |
44 ```javascript | |
45 this.$.meta.byKey('info').getAttribute('value'); | |
46 ``` | |
OLD | NEW |