Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: third_party/polymer/v1_0/components-chromium/iron-meta/iron-meta-extracted.js

Issue 1221923003: Update bower.json for Polymer elements and add PRESUBMIT.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 2
3 (function() { 3 (function() {
4 4
5 // monostate data 5 // monostate data
6 var metaDatas = {}; 6 var metaDatas = {};
7 var metaArrays = {}; 7 var metaArrays = {};
8 8
9 Polymer.IronMeta = Polymer({ 9 Polymer.IronMeta = Polymer({
10 10
11 is: 'iron-meta', 11 is: 'iron-meta',
12 12
13 properties: { 13 properties: {
14 14
15 /** 15 /**
16 * The type of meta-data. All meta-data of the same type is stored 16 * The type of meta-data. All meta-data of the same type is stored
17 * together. 17 * together.
18 *
19 * @attribute type
20 * @type String
21 * @default 'default'
22 */ 18 */
23 type: { 19 type: {
24 type: String, 20 type: String,
25 value: 'default', 21 value: 'default',
26 observer: '_typeChanged' 22 observer: '_typeChanged'
27 }, 23 },
28 24
29 /** 25 /**
30 * The key used to store `value` under the `type` namespace. 26 * The key used to store `value` under the `type` namespace.
31 *
32 * @attribute key
33 * @type String
34 * @default ''
35 */ 27 */
36 key: { 28 key: {
37 type: String, 29 type: String,
38 observer: '_keyChanged' 30 observer: '_keyChanged'
39 }, 31 },
40 32
41 /** 33 /**
42 * The meta-data to store or retrieve. 34 * The meta-data to store or retrieve.
43 *
44 * @attribute value
45 * @type *
46 * @default this
47 */ 35 */
48 value: { 36 value: {
49 type: Object, 37 type: Object,
50 notify: true, 38 notify: true,
51 observer: '_valueChanged' 39 observer: '_valueChanged'
52 }, 40 },
53 41
54 /** 42 /**
55 * If true, `value` is set to the iron-meta instance itself. 43 * If true, `value` is set to the iron-meta instance itself.
56 *
57 * @attribute self
58 * @type Boolean
59 * @default false
60 */ 44 */
61 self: { 45 self: {
62 type: Boolean, 46 type: Boolean,
63 observer: '_selfChanged' 47 observer: '_selfChanged'
64 }, 48 },
65 49
66 /** 50 /**
67 * Array of all meta-data values for the given type. 51 * Array of all meta-data values for the given type.
68 *
69 * @property list
70 * @type Array
71 */ 52 */
72 list: { 53 list: {
73 type: Array, 54 type: Array,
74 notify: true 55 notify: true
75 } 56 }
76 57
77 }, 58 },
78 59
79 /** 60 /**
80 * Only runs if someone invokes the factory/constructor directly 61 * Only runs if someone invokes the factory/constructor directly
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 metaArrays[type] = []; 105 metaArrays[type] = [];
125 } 106 }
126 this.list = metaArrays[type]; 107 this.list = metaArrays[type];
127 this._registerKeyValue(this.key, this.value); 108 this._registerKeyValue(this.key, this.value);
128 }, 109 },
129 110
130 /** 111 /**
131 * Retrieves meta data value by key. 112 * Retrieves meta data value by key.
132 * 113 *
133 * @method byKey 114 * @method byKey
134 * @param {String} key The key of the meta-data to be returned. 115 * @param {string} key The key of the meta-data to be returned.
135 * @returns * 116 * @return {*}
136 */ 117 */
137 byKey: function(key) { 118 byKey: function(key) {
138 return this._metaData && this._metaData[key]; 119 return this._metaData && this._metaData[key];
139 }, 120 },
140 121
141 _resetRegistration: function(oldKey) { 122 _resetRegistration: function(oldKey) {
142 this._unregisterKey(oldKey); 123 this._unregisterKey(oldKey);
143 this._registerKeyValue(this.key, this.value); 124 this._registerKeyValue(this.key, this.value);
144 }, 125 },
145 126
(...skipping 26 matching lines...) Expand all
172 153
173 /** 154 /**
174 `iron-meta-query` can be used to access infomation stored in `iron-meta`. 155 `iron-meta-query` can be used to access infomation stored in `iron-meta`.
175 156
176 Examples: 157 Examples:
177 158
178 If I create an instance like this: 159 If I create an instance like this:
179 160
180 <iron-meta key="info" value="foo/bar"></iron-meta> 161 <iron-meta key="info" value="foo/bar"></iron-meta>
181 162
182 Note that keyUrl="foo/bar" is the metadata I've defined. I could define more 163 Note that value="foo/bar" is the metadata I've defined. I could define more
183 attributes or use child nodes to define additional metadata. 164 attributes or use child nodes to define additional metadata.
184 165
185 Now I can access that element (and it's metadata) from any `iron-meta-query` instance: 166 Now I can access that element (and it's metadata) from any `iron-meta-query` instance:
186 167
187 var value = new Polymer.IronMetaQuery({key: 'info'}).value; 168 var value = new Polymer.IronMetaQuery({key: 'info'}).value;
188 169
189 @group Polymer Iron Elements 170 @group Polymer Iron Elements
190 @element iron-meta-query 171 @element iron-meta-query
191 */ 172 */
192 Polymer.IronMetaQuery = Polymer({ 173 Polymer.IronMetaQuery = Polymer({
193 174
194 is: 'iron-meta-query', 175 is: 'iron-meta-query',
195 176
196 properties: { 177 properties: {
197 178
198 /** 179 /**
199 * The type of meta-data. All meta-data of the same type is stored 180 * The type of meta-data. All meta-data of the same type is stored
200 * together. 181 * together.
201 *
202 * @attribute type
203 * @type String
204 * @default 'default'
205 */ 182 */
206 type: { 183 type: {
207 type: String, 184 type: String,
208 value: 'default', 185 value: 'default',
209 observer: '_typeChanged' 186 observer: '_typeChanged'
210 }, 187 },
211 188
212 /** 189 /**
213 * Specifies a key to use for retrieving `value` from the `type` 190 * Specifies a key to use for retrieving `value` from the `type`
214 * namespace. 191 * namespace.
215 *
216 * @attribute key
217 * @type String
218 */ 192 */
219 key: { 193 key: {
220 type: String, 194 type: String,
221 observer: '_keyChanged' 195 observer: '_keyChanged'
222 }, 196 },
223 197
224 /** 198 /**
225 * The meta-data to store or retrieve. 199 * The meta-data to store or retrieve.
226 *
227 * @attribute value
228 * @type *
229 * @default this
230 */ 200 */
231 value: { 201 value: {
232 type: Object, 202 type: Object,
233 notify: true, 203 notify: true,
234 readOnly: true 204 readOnly: true
235 }, 205 },
236 206
237 /** 207 /**
238 * Array of all meta-data values for the given type. 208 * Array of all meta-data values for the given type.
239 *
240 * @property list
241 * @type Array
242 */ 209 */
243 list: { 210 list: {
244 type: Array, 211 type: Array,
245 notify: true 212 notify: true
246 } 213 }
247 214
248 }, 215 },
249 216
250 /** 217 /**
251 * Actually a factory method, not a true constructor. Only runs if 218 * Actually a factory method, not a true constructor. Only runs if
252 * someone invokes it directly (via `new Polymer.IronMeta()`); 219 * someone invokes it directly (via `new Polymer.IronMeta()`);
253 */ 220 */
254 constructor: function(config) { 221 factoryImpl: function(config) {
255 if (config) { 222 if (config) {
256 for (var n in config) { 223 for (var n in config) {
257 switch(n) { 224 switch(n) {
258 case 'type': 225 case 'type':
259 case 'key': 226 case 'key':
260 this[n] = config[n]; 227 this[n] = config[n];
261 break; 228 break;
262 } 229 }
263 } 230 }
264 } 231 }
(...skipping 12 matching lines...) Expand all
277 _typeChanged: function(type) { 244 _typeChanged: function(type) {
278 this._metaData = metaDatas[type]; 245 this._metaData = metaDatas[type];
279 this.list = metaArrays[type]; 246 this.list = metaArrays[type];
280 if (this.key) { 247 if (this.key) {
281 this._keyChanged(this.key); 248 this._keyChanged(this.key);
282 } 249 }
283 }, 250 },
284 251
285 /** 252 /**
286 * Retrieves meta data value by key. 253 * Retrieves meta data value by key.
287 * 254 * @param {string} key The key of the meta-data to be returned.
288 * @method byKey 255 * @return {*}
289 * @param {String} key The key of the meta-data to be returned.
290 * @returns *
291 */ 256 */
292 byKey: function(key) { 257 byKey: function(key) {
293 return this._metaData && this._metaData[key]; 258 return this._metaData && this._metaData[key];
294 } 259 }
295 260
296 }); 261 });
297 262
298 })(); 263 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698