Chromecast: registers old client_id metrics pref.
[chromium-blink-merge.git] / third_party / polymer / v0_8 / components / iron-meta / README.md
blobb3b0f273b6bc6ef92a60d31a9c3c5e2f524e36a5
1 iron-meta
2 =========
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 any
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 extension
8 [like x-meta] for enhancements).
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 them
12 before you try to access them.
14 Examples:
16 If I create an instance like this:
18 ```html
19 <iron-meta key="info" keyUrl="foo/bar"></iron-meta>
20 ```
22 Note that keyUrl="foo/bar" is the metadata I've defined. I could define more
23 attributes or use child nodes to define additional metadata.
25 Now I can access that element (and it's metadata) from any iron-meta instance
26 via the byKey method, e.g.
28 ```javascript
29 meta.byKey('info').getAttribute('keyUrl').
30 ```
32 Pure imperative form would be like:
34 ```javascript
35 document.createElement('iron-meta').byKey('info').getAttribute('keyUrl');
36 ```
38 Or, in a Polymer element, you can include a meta in your template:
40 ```html
41 <iron-meta id="meta"></iron-meta>
42 ```
44 ```javascript
45 this.$.meta.byKey('info').getAttribute('keyUrl');
46 ```