• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2<!---
3
4This README is automatically generated from the comments in these files:
5iron-meta.html
6
7Edit those files, and our readme bot will duplicate them over here!
8Edit this file, and the bot will squash your changes :)
9
10The bot does some handling of markdown. Please file a bug if it does the wrong
11thing! https://github.com/PolymerLabs/tedium/issues
12
13-->
14
15[![Build status](https://travis-ci.org/PolymerElements/iron-meta.svg?branch=master)](https://travis-ci.org/PolymerElements/iron-meta)
16
17_[Demo and API docs](https://elements.polymer-project.org/elements/iron-meta)_
18
19
20##&lt;iron-meta&gt;
21
22`iron-meta` is a generic element you can use for sharing information across the DOM tree.
23It uses [monostate pattern](http://c2.com/cgi/wiki?MonostatePattern) such that any
24instance of iron-meta has access to the shared
25information. You can use `iron-meta` to share whatever you want (or create an extension
26[like x-meta] for enhancements).
27
28The `iron-meta` instances containing your actual data can be loaded in an import,
29or constructed in any way you see fit. The only requirement is that you create them
30before you try to access them.
31
32Examples:
33
34If I create an instance like this:
35
36```html
37<iron-meta key="info" value="foo/bar"></iron-meta>
38```
39
40Note that value="foo/bar" is the metadata I've defined. I could define more
41attributes or use child nodes to define additional metadata.
42
43Now I can access that element (and it's metadata) from any iron-meta instance
44via the byKey method, e.g.
45
46```javascript
47meta.byKey('info');
48```
49
50Pure imperative form would be like:
51
52```javascript
53document.createElement('iron-meta').byKey('info');
54```
55
56Or, in a Polymer element, you can include a meta in your template:
57
58```html
59<iron-meta id="meta"></iron-meta>
60...
61this.$.meta.byKey('info');
62```
63
64
65
66##&lt;iron-meta-query&gt;
67
68`iron-meta` is a generic element you can use for sharing information across the DOM tree.
69It uses [monostate pattern](http://c2.com/cgi/wiki?MonostatePattern) such that any
70instance of iron-meta has access to the shared
71information. You can use `iron-meta` to share whatever you want (or create an extension
72[like x-meta] for enhancements).
73
74The `iron-meta` instances containing your actual data can be loaded in an import,
75or constructed in any way you see fit. The only requirement is that you create them
76before you try to access them.
77
78Examples:
79
80If I create an instance like this:
81
82```html
83<iron-meta key="info" value="foo/bar"></iron-meta>
84```
85
86Note that value="foo/bar" is the metadata I've defined. I could define more
87attributes or use child nodes to define additional metadata.
88
89Now I can access that element (and it's metadata) from any iron-meta instance
90via the byKey method, e.g.
91
92```javascript
93meta.byKey('info');
94```
95
96Pure imperative form would be like:
97
98```javascript
99document.createElement('iron-meta').byKey('info');
100```
101
102Or, in a Polymer element, you can include a meta in your template:
103
104```html
105<iron-meta id="meta"></iron-meta>
106...
107this.$.meta.byKey('info');
108```
109
110
111