Blame view

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