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 10--> 11 12[](https://travis-ci.org/PolymerElements/iron-meta) 13 14_[Demo and API Docs](https://elements.polymer-project.org/elements/iron-meta)_ 15 16 17##<iron-meta> 18 19 20`iron-meta` is a generic element you can use for sharing information across the DOM tree. 21It uses [monostate pattern](http://c2.com/cgi/wiki?MonostatePattern) such that any 22instance of iron-meta has access to the shared 23information. You can use `iron-meta` to share whatever you want (or create an extension 24[like x-meta] for enhancements). 25 26The `iron-meta` instances containing your actual data can be loaded in an import, 27or constructed in any way you see fit. The only requirement is that you create them 28before you try to access them. 29 30Examples: 31 32If I create an instance like this: 33 34 <iron-meta key="info" value="foo/bar"></iron-meta> 35 36Note that value="foo/bar" is the metadata I've defined. I could define more 37attributes or use child nodes to define additional metadata. 38 39Now I can access that element (and it's metadata) from any iron-meta instance 40via the byKey method, e.g. 41 42 meta.byKey('info').getAttribute('value'); 43 44Pure imperative form would be like: 45 46 document.createElement('iron-meta').byKey('info').getAttribute('value'); 47 48Or, 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##<iron-meta-query> 57 58 59`iron-meta` is a generic element you can use for sharing information across the DOM tree. 60It uses [monostate pattern](http://c2.com/cgi/wiki?MonostatePattern) such that any 61instance of iron-meta has access to the shared 62information. You can use `iron-meta` to share whatever you want (or create an extension 63[like x-meta] for enhancements). 64 65The `iron-meta` instances containing your actual data can be loaded in an import, 66or constructed in any way you see fit. The only requirement is that you create them 67before you try to access them. 68 69Examples: 70 71If I create an instance like this: 72 73 <iron-meta key="info" value="foo/bar"></iron-meta> 74 75Note that value="foo/bar" is the metadata I've defined. I could define more 76attributes or use child nodes to define additional metadata. 77 78Now I can access that element (and it's metadata) from any iron-meta instance 79via the byKey method, e.g. 80 81 meta.byKey('info').getAttribute('value'); 82 83Pure imperative form would be like: 84 85 document.createElement('iron-meta').byKey('info').getAttribute('value'); 86 87Or, 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