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 --> | 9 --> |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 @element iron-meta | 51 @element iron-meta |
52 --> | 52 --> |
53 | 53 |
54 <script> | 54 <script> |
55 | 55 |
56 (function() { | 56 (function() { |
57 | 57 |
58 // monostate data | 58 // monostate data |
59 var metaDatas = {}; | 59 var metaDatas = {}; |
60 var metaArrays = {}; | 60 var metaArrays = {}; |
| 61 var singleton = null; |
61 | 62 |
62 Polymer.IronMeta = Polymer({ | 63 Polymer.IronMeta = Polymer({ |
63 | 64 |
64 is: 'iron-meta', | 65 is: 'iron-meta', |
65 | 66 |
66 properties: { | 67 properties: { |
67 | 68 |
68 /** | 69 /** |
69 * The type of meta-data. All meta-data of the same type is stored | 70 * The type of meta-data. All meta-data of the same type is stored |
70 * together. | 71 * together. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 /** | 104 /** |
104 * Array of all meta-data values for the given type. | 105 * Array of all meta-data values for the given type. |
105 */ | 106 */ |
106 list: { | 107 list: { |
107 type: Array, | 108 type: Array, |
108 notify: true | 109 notify: true |
109 } | 110 } |
110 | 111 |
111 }, | 112 }, |
112 | 113 |
| 114 hostAttributes: { |
| 115 hidden: true |
| 116 }, |
| 117 |
113 /** | 118 /** |
114 * Only runs if someone invokes the factory/constructor directly | 119 * Only runs if someone invokes the factory/constructor directly |
115 * e.g. `new Polymer.IronMeta()` | 120 * e.g. `new Polymer.IronMeta()` |
116 */ | 121 */ |
117 factoryImpl: function(config) { | 122 factoryImpl: function(config) { |
118 if (config) { | 123 if (config) { |
119 for (var n in config) { | 124 for (var n in config) { |
120 switch(n) { | 125 switch(n) { |
121 case 'type': | 126 case 'type': |
122 case 'key': | 127 case 'key': |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 if (key in data) { | 202 if (key in data) { |
198 var value = data[key]; | 203 var value = data[key]; |
199 delete data[key]; | 204 delete data[key]; |
200 this.arrayDelete(list, value); | 205 this.arrayDelete(list, value); |
201 } | 206 } |
202 } | 207 } |
203 } | 208 } |
204 | 209 |
205 }); | 210 }); |
206 | 211 |
| 212 Polymer.IronMeta.getIronMeta = function getIronMeta() { |
| 213 if (singleton === null) { |
| 214 singleton = new Polymer.IronMeta(); |
| 215 } |
| 216 return singleton; |
| 217 }; |
| 218 |
207 /** | 219 /** |
208 `iron-meta-query` can be used to access infomation stored in `iron-meta`. | 220 `iron-meta-query` can be used to access infomation stored in `iron-meta`. |
209 | 221 |
210 Examples: | 222 Examples: |
211 | 223 |
212 If I create an instance like this: | 224 If I create an instance like this: |
213 | 225 |
214 <iron-meta key="info" value="foo/bar"></iron-meta> | 226 <iron-meta key="info" value="foo/bar"></iron-meta> |
215 | 227 |
216 Note that value="foo/bar" is the metadata I've defined. I could define more | 228 Note that value="foo/bar" is the metadata I've defined. I could define more |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 * @return {*} | 320 * @return {*} |
309 */ | 321 */ |
310 byKey: function(key) { | 322 byKey: function(key) { |
311 return this._metaData && this._metaData[key]; | 323 return this._metaData && this._metaData[key]; |
312 } | 324 } |
313 | 325 |
314 }); | 326 }); |
315 | 327 |
316 })(); | 328 })(); |
317 </script> | 329 </script> |
OLD | NEW |