OLD | NEW |
1 <!-- | 1 <!-- |
2 @license | 2 @license |
3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
7 Code distributed by Google as part of the polymer project is also | 7 Code distributed by Google as part of the polymer project is also |
8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
9 --><html><head><link rel="import" href="../polymer/polymer.html"> | 9 --><html><head><link rel="import" href="../polymer/polymer.html"> |
10 | 10 |
11 <!-- | 11 <!-- |
12 `iron-meta` is a generic element you can use for sharing information across the
DOM tree. | 12 `iron-meta` is a generic element you can use for sharing information across the
DOM tree. |
13 It uses [monostate pattern](http://c2.com/cgi/wiki?MonostatePattern) such that a
ny | 13 It uses [monostate pattern](http://c2.com/cgi/wiki?MonostatePattern) such that a
ny |
14 instance of iron-meta has access to the shared | 14 instance of iron-meta has access to the shared |
15 information. You can use `iron-meta` to share whatever you want (or create an ex
tension | 15 information. You can use `iron-meta` to share whatever you want (or create an ex
tension |
16 [like x-meta] for enhancements). | 16 [like x-meta] for enhancements). |
17 | 17 |
18 The `iron-meta` instances containing your actual data can be loaded in an import
, | 18 The `iron-meta` instances containing your actual data can be loaded in an import
, |
19 or constructed in any way you see fit. The only requirement is that you create t
hem | 19 or constructed in any way you see fit. The only requirement is that you create t
hem |
20 before you try to access them. | 20 before you try to access them. |
21 | 21 |
22 Examples: | 22 Examples: |
23 | 23 |
24 If I create an instance like this: | 24 If I create an instance like this: |
25 | 25 |
26 <iron-meta key="info" keyUrl="foo/bar"></iron-meta> | 26 <iron-meta key="info" value="foo/bar"></iron-meta> |
27 | 27 |
28 Note that keyUrl="foo/bar" is the metadata I've defined. I could define more | 28 Note that value="foo/bar" is the metadata I've defined. I could define more |
29 attributes or use child nodes to define additional metadata. | 29 attributes or use child nodes to define additional metadata. |
30 | 30 |
31 Now I can access that element (and it's metadata) from any iron-meta instance | 31 Now I can access that element (and it's metadata) from any iron-meta instance |
32 via the byKey method, e.g. | 32 via the byKey method, e.g. |
33 | 33 |
34 meta.byKey('info').getAttribute('keyUrl'). | 34 meta.byKey('info').getAttribute('value'). |
35 | 35 |
36 Pure imperative form would be like: | 36 Pure imperative form would be like: |
37 | 37 |
38 document.createElement('iron-meta').byKey('info').getAttribute('keyUrl'); | 38 document.createElement('iron-meta').byKey('info').getAttribute('value'); |
39 | 39 |
40 Or, in a Polymer element, you can include a meta in your template: | 40 Or, in a Polymer element, you can include a meta in your template: |
41 | 41 |
42 <iron-meta id="meta"></iron-meta> | 42 <iron-meta id="meta"></iron-meta> |
43 ... | 43 ... |
44 this.$.meta.byKey('info').getAttribute('keyUrl'); | 44 this.$.meta.byKey('info').getAttribute('value'); |
45 | 45 |
46 @group Iron Elements | 46 @group Iron Elements |
47 @demo demo/index.html | 47 @demo demo/index.html |
48 @hero hero.svg | 48 @hero hero.svg |
49 @element iron-meta | 49 @element iron-meta |
50 --> | 50 --> |
51 | 51 |
52 </head><body><script src="iron-meta-extracted.js"></script></body></html> | 52 </head><body><script src="iron-meta-extracted.js"></script></body></html> |
OLD | NEW |