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