OLD | NEW |
1 (function () { | 1 (function () { |
2 function resolve() { | 2 function resolve() { |
3 document.body.removeAttribute('unresolved'); | 3 document.body.removeAttribute('unresolved'); |
4 } | 4 } |
5 if (window.WebComponents) { | 5 if (window.WebComponents) { |
6 addEventListener('WebComponentsReady', resolve); | 6 addEventListener('WebComponentsReady', resolve); |
7 } else { | 7 } else { |
8 if (document.readyState === 'interactive' || document.readyState === 'complete')
{ | 8 if (document.readyState === 'interactive' || document.readyState === 'complete')
{ |
9 resolve(); | 9 resolve(); |
10 } else { | 10 } else { |
11 addEventListener('DOMContentLoaded', resolve); | 11 addEventListener('DOMContentLoaded', resolve); |
12 } | 12 } |
13 } | 13 } |
14 }()); | 14 }()); |
15 window.Polymer = { | 15 window.Polymer = { |
16 Settings: function () { | 16 Settings: function () { |
17 var user = window.Polymer || {}; | 17 var user = window.Polymer || {}; |
18 location.search.slice(1).split('&').forEach(function (o) { | 18 var parts = location.search.slice(1).split('&'); |
| 19 for (var i = 0, o; i < parts.length && (o = parts[i]); i++) { |
19 o = o.split('='); | 20 o = o.split('='); |
20 o[0] && (user[o[0]] = o[1] || true); | 21 o[0] && (user[o[0]] = o[1] || true); |
21 }); | 22 } |
22 var wantShadow = user.dom === 'shadow'; | 23 var wantShadow = user.dom === 'shadow'; |
23 var hasShadow = Boolean(Element.prototype.createShadowRoot); | 24 var hasShadow = Boolean(Element.prototype.createShadowRoot); |
24 var nativeShadow = hasShadow && !window.ShadowDOMPolyfill; | 25 var nativeShadow = hasShadow && !window.ShadowDOMPolyfill; |
25 var useShadow = wantShadow && hasShadow; | 26 var useShadow = wantShadow && hasShadow; |
26 var hasNativeImports = Boolean('import' in document.createElement('link')); | 27 var hasNativeImports = Boolean('import' in document.createElement('link')); |
27 var useNativeImports = hasNativeImports; | 28 var useNativeImports = hasNativeImports; |
28 var useNativeCustomElements = !window.CustomElements || window.CustomElements.us
eNative; | 29 var useNativeCustomElements = !window.CustomElements || window.CustomElements.us
eNative; |
29 return { | 30 return { |
30 wantShadow: wantShadow, | 31 wantShadow: wantShadow, |
31 hasShadow: hasShadow, | 32 hasShadow: hasShadow, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 _callbacks: [], | 99 _callbacks: [], |
99 whenReady: function (cb) { | 100 whenReady: function (cb) { |
100 if (this._ready) { | 101 if (this._ready) { |
101 cb(); | 102 cb(); |
102 } else { | 103 } else { |
103 this._callbacks.push(cb); | 104 this._callbacks.push(cb); |
104 } | 105 } |
105 }, | 106 }, |
106 _makeReady: function () { | 107 _makeReady: function () { |
107 this._ready = true; | 108 this._ready = true; |
108 this._callbacks.forEach(function (cb) { | 109 for (var i = 0; i < this._callbacks.length; i++) { |
109 cb(); | 110 this._callbacks[i](); |
110 }); | 111 } |
111 this._callbacks = []; | 112 this._callbacks = []; |
112 }, | 113 }, |
113 _catchFirstRender: function () { | 114 _catchFirstRender: function () { |
114 requestAnimationFrame(function () { | 115 requestAnimationFrame(function () { |
115 Polymer.RenderStatus._makeReady(); | 116 Polymer.RenderStatus._makeReady(); |
116 }); | 117 }); |
| 118 }, |
| 119 _afterNextRenderQueue: [], |
| 120 _waitingNextRender: false, |
| 121 afterNextRender: function (element, fn, args) { |
| 122 this._watchNextRender(); |
| 123 this._afterNextRenderQueue.push([ |
| 124 element, |
| 125 fn, |
| 126 args |
| 127 ]); |
| 128 }, |
| 129 _watchNextRender: function () { |
| 130 if (!this._waitingNextRender) { |
| 131 this._waitingNextRender = true; |
| 132 var fn = function () { |
| 133 Polymer.RenderStatus._flushNextRender(); |
| 134 }; |
| 135 if (!this._ready) { |
| 136 this.whenReady(fn); |
| 137 } else { |
| 138 requestAnimationFrame(fn); |
| 139 } |
| 140 } |
| 141 }, |
| 142 _flushNextRender: function () { |
| 143 var self = this; |
| 144 setTimeout(function () { |
| 145 self._flushRenderCallbacks(self._afterNextRenderQueue); |
| 146 self._afterNextRenderQueue = []; |
| 147 self._waitingNextRender = false; |
| 148 }); |
| 149 }, |
| 150 _flushRenderCallbacks: function (callbacks) { |
| 151 for (var i = 0, h; i < callbacks.length; i++) { |
| 152 h = callbacks[i]; |
| 153 h[1].apply(h[0], h[2] || Polymer.nar); |
| 154 } |
| 155 ; |
117 } | 156 } |
118 }; | 157 }; |
119 if (window.HTMLImports) { | 158 if (window.HTMLImports) { |
120 HTMLImports.whenReady(function () { | 159 HTMLImports.whenReady(function () { |
121 Polymer.RenderStatus._catchFirstRender(); | 160 Polymer.RenderStatus._catchFirstRender(); |
122 }); | 161 }); |
123 } else { | 162 } else { |
124 Polymer.RenderStatus._catchFirstRender(); | 163 Polymer.RenderStatus._catchFirstRender(); |
125 } | 164 } |
126 Polymer.ImportStatus = Polymer.RenderStatus; | 165 Polymer.ImportStatus = Polymer.RenderStatus; |
127 Polymer.ImportStatus.whenLoaded = Polymer.ImportStatus.whenReady; | 166 Polymer.ImportStatus.whenLoaded = Polymer.ImportStatus.whenReady; |
128 Polymer.Base = { | 167 Polymer.Base = { |
129 __isPolymerInstance__: true, | 168 __isPolymerInstance__: true, |
130 _addFeature: function (feature) { | 169 _addFeature: function (feature) { |
131 this.extend(this, feature); | 170 this.extend(this, feature); |
132 }, | 171 }, |
133 registerCallback: function () { | 172 registerCallback: function () { |
134 this._desugarBehaviors(); | 173 this._desugarBehaviors(); |
135 this._doBehavior('beforeRegister'); | 174 this._doBehavior('beforeRegister'); |
136 this._registerFeatures(); | 175 this._registerFeatures(); |
137 this._doBehavior('registered'); | 176 this._doBehavior('registered'); |
138 }, | 177 }, |
139 createdCallback: function () { | 178 createdCallback: function () { |
140 Polymer.telemetry.instanceCount++; | 179 Polymer.telemetry.instanceCount++; |
141 this.root = this; | 180 this.root = this; |
142 this._doBehavior('created'); | 181 this._doBehavior('created'); |
143 this._initFeatures(); | 182 this._initFeatures(); |
144 }, | 183 }, |
145 attachedCallback: function () { | 184 attachedCallback: function () { |
| 185 var self = this; |
146 Polymer.RenderStatus.whenReady(function () { | 186 Polymer.RenderStatus.whenReady(function () { |
147 this.isAttached = true; | 187 self.isAttached = true; |
148 this._doBehavior('attached'); | 188 self._doBehavior('attached'); |
149 }.bind(this)); | 189 }); |
150 }, | 190 }, |
151 detachedCallback: function () { | 191 detachedCallback: function () { |
152 this.isAttached = false; | 192 this.isAttached = false; |
153 this._doBehavior('detached'); | 193 this._doBehavior('detached'); |
154 }, | 194 }, |
155 attributeChangedCallback: function (name) { | 195 attributeChangedCallback: function (name, oldValue, newValue) { |
156 this._attributeChangedImpl(name); | 196 this._attributeChangedImpl(name); |
157 this._doBehavior('attributeChanged', arguments); | 197 this._doBehavior('attributeChanged', [ |
| 198 name, |
| 199 oldValue, |
| 200 newValue |
| 201 ]); |
158 }, | 202 }, |
159 _attributeChangedImpl: function (name) { | 203 _attributeChangedImpl: function (name) { |
160 this._setAttributeToProperty(this, name); | 204 this._setAttributeToProperty(this, name); |
161 }, | 205 }, |
162 extend: function (prototype, api) { | 206 extend: function (prototype, api) { |
163 if (prototype && api) { | 207 if (prototype && api) { |
164 Object.getOwnPropertyNames(api).forEach(function (n) { | 208 var n$ = Object.getOwnPropertyNames(api); |
| 209 for (var i = 0, n; i < n$.length && (n = n$[i]); i++) { |
165 this.copyOwnProperty(n, api, prototype); | 210 this.copyOwnProperty(n, api, prototype); |
166 }, this); | 211 } |
167 } | 212 } |
168 return prototype || api; | 213 return prototype || api; |
169 }, | 214 }, |
170 mixin: function (target, source) { | 215 mixin: function (target, source) { |
171 for (var i in source) { | 216 for (var i in source) { |
172 target[i] = source[i]; | 217 target[i] = source[i]; |
173 } | 218 } |
174 return target; | 219 return target; |
175 }, | 220 }, |
176 copyOwnProperty: function (name, source, target) { | 221 copyOwnProperty: function (name, source, target) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 if (id) { | 279 if (id) { |
235 this.id = id; | 280 this.id = id; |
236 modules[id] = this; | 281 modules[id] = this; |
237 lcModules[id.toLowerCase()] = this; | 282 lcModules[id.toLowerCase()] = this; |
238 } | 283 } |
239 }, | 284 }, |
240 import: function (id, selector) { | 285 import: function (id, selector) { |
241 if (id) { | 286 if (id) { |
242 var m = findModule(id); | 287 var m = findModule(id); |
243 if (!m) { | 288 if (!m) { |
244 forceDocumentUpgrade(); | 289 forceDomModulesUpgrade(); |
245 m = findModule(id); | 290 m = findModule(id); |
246 } | 291 } |
247 if (m && selector) { | 292 if (m && selector) { |
248 m = m.querySelector(selector); | 293 m = m.querySelector(selector); |
249 } | 294 } |
250 return m; | 295 return m; |
251 } | 296 } |
252 } | 297 } |
253 }); | 298 }); |
254 var cePolyfill = window.CustomElements && !CustomElements.useNative; | 299 var cePolyfill = window.CustomElements && !CustomElements.useNative; |
255 document.registerElement('dom-module', DomModule); | 300 document.registerElement('dom-module', DomModule); |
256 function forceDocumentUpgrade() { | 301 function forceDomModulesUpgrade() { |
257 if (cePolyfill) { | 302 if (cePolyfill) { |
258 var script = document._currentScript || document.currentScript; | 303 var script = document._currentScript || document.currentScript; |
259 var doc = script && script.ownerDocument || document; | 304 var doc = script && script.ownerDocument || document; |
260 if (doc) { | 305 var modules = doc.querySelectorAll('dom-module'); |
261 CustomElements.upgradeAll(doc); | 306 for (var i = modules.length - 1, m; i >= 0 && (m = modules[i]); i--) { |
| 307 if (m.__upgraded__) { |
| 308 return; |
| 309 } else { |
| 310 CustomElements.upgrade(m); |
262 } | 311 } |
263 } | 312 } |
264 } | 313 } |
| 314 } |
265 }()); | 315 }()); |
266 Polymer.Base._addFeature({ | 316 Polymer.Base._addFeature({ |
267 _prepIs: function () { | 317 _prepIs: function () { |
268 if (!this.is) { | 318 if (!this.is) { |
269 var module = (document._currentScript || document.currentScript).parentNode; | 319 var module = (document._currentScript || document.currentScript).parentNode; |
270 if (module.localName === 'dom-module') { | 320 if (module.localName === 'dom-module') { |
271 var id = module.id || module.getAttribute('name') || module.getAttribute('is'); | 321 var id = module.id || module.getAttribute('name') || module.getAttribute('is'); |
272 this.is = id; | 322 this.is = id; |
273 } | 323 } |
274 } | 324 } |
(...skipping 11 matching lines...) Expand all Loading... |
286 }, | 336 }, |
287 _desugarSomeBehaviors: function (behaviors) { | 337 _desugarSomeBehaviors: function (behaviors) { |
288 behaviors = this._flattenBehaviorsList(behaviors); | 338 behaviors = this._flattenBehaviorsList(behaviors); |
289 for (var i = behaviors.length - 1; i >= 0; i--) { | 339 for (var i = behaviors.length - 1; i >= 0; i--) { |
290 this._mixinBehavior(behaviors[i]); | 340 this._mixinBehavior(behaviors[i]); |
291 } | 341 } |
292 return behaviors; | 342 return behaviors; |
293 }, | 343 }, |
294 _flattenBehaviorsList: function (behaviors) { | 344 _flattenBehaviorsList: function (behaviors) { |
295 var flat = []; | 345 var flat = []; |
296 behaviors.forEach(function (b) { | 346 for (var i = 0; i < behaviors.length; i++) { |
| 347 var b = behaviors[i]; |
297 if (b instanceof Array) { | 348 if (b instanceof Array) { |
298 flat = flat.concat(this._flattenBehaviorsList(b)); | 349 flat = flat.concat(this._flattenBehaviorsList(b)); |
299 } else if (b) { | 350 } else if (b) { |
300 flat.push(b); | 351 flat.push(b); |
301 } else { | 352 } else { |
302 this._warn(this._logf('_flattenBehaviorsList', 'behavior is null, check for miss
ing or 404 import')); | 353 this._warn(this._logf('_flattenBehaviorsList', 'behavior is null, check for miss
ing or 404 import')); |
303 } | 354 } |
304 }, this); | 355 } |
305 return flat; | 356 return flat; |
306 }, | 357 }, |
307 _mixinBehavior: function (b) { | 358 _mixinBehavior: function (b) { |
308 Object.getOwnPropertyNames(b).forEach(function (n) { | 359 var n$ = Object.getOwnPropertyNames(b); |
309 switch (n) { | 360 for (var i = 0, n; i < n$.length && (n = n$[i]); i++) { |
310 case 'hostAttributes': | 361 if (!Polymer.Base._behaviorProperties[n] && !this.hasOwnProperty(n)) { |
311 case 'registered': | |
312 case 'properties': | |
313 case 'observers': | |
314 case 'listeners': | |
315 case 'created': | |
316 case 'attached': | |
317 case 'detached': | |
318 case 'attributeChanged': | |
319 case 'configure': | |
320 case 'ready': | |
321 break; | |
322 default: | |
323 if (!this.hasOwnProperty(n)) { | |
324 this.copyOwnProperty(n, b, this); | 362 this.copyOwnProperty(n, b, this); |
325 } | 363 } |
326 break; | |
327 } | 364 } |
328 }, this); | |
329 }, | 365 }, |
330 _prepBehaviors: function () { | 366 _prepBehaviors: function () { |
331 this._prepFlattenedBehaviors(this.behaviors); | 367 this._prepFlattenedBehaviors(this.behaviors); |
332 }, | 368 }, |
333 _prepFlattenedBehaviors: function (behaviors) { | 369 _prepFlattenedBehaviors: function (behaviors) { |
334 for (var i = 0, l = behaviors.length; i < l; i++) { | 370 for (var i = 0, l = behaviors.length; i < l; i++) { |
335 this._prepBehavior(behaviors[i]); | 371 this._prepBehavior(behaviors[i]); |
336 } | 372 } |
337 this._prepBehavior(this); | 373 this._prepBehavior(this); |
338 }, | 374 }, |
339 _doBehavior: function (name, args) { | 375 _doBehavior: function (name, args) { |
340 this.behaviors.forEach(function (b) { | 376 for (var i = 0; i < this.behaviors.length; i++) { |
341 this._invokeBehavior(b, name, args); | 377 this._invokeBehavior(this.behaviors[i], name, args); |
342 }, this); | 378 } |
343 this._invokeBehavior(this, name, args); | 379 this._invokeBehavior(this, name, args); |
344 }, | 380 }, |
345 _invokeBehavior: function (b, name, args) { | 381 _invokeBehavior: function (b, name, args) { |
346 var fn = b[name]; | 382 var fn = b[name]; |
347 if (fn) { | 383 if (fn) { |
348 fn.apply(this, args || Polymer.nar); | 384 fn.apply(this, args || Polymer.nar); |
349 } | 385 } |
350 }, | 386 }, |
351 _marshalBehaviors: function () { | 387 _marshalBehaviors: function () { |
352 this.behaviors.forEach(function (b) { | 388 for (var i = 0; i < this.behaviors.length; i++) { |
353 this._marshalBehavior(b); | 389 this._marshalBehavior(this.behaviors[i]); |
354 }, this); | 390 } |
355 this._marshalBehavior(this); | 391 this._marshalBehavior(this); |
356 } | 392 } |
357 }); | 393 }); |
| 394 Polymer.Base._behaviorProperties = { |
| 395 hostAttributes: true, |
| 396 registered: true, |
| 397 properties: true, |
| 398 observers: true, |
| 399 listeners: true, |
| 400 created: true, |
| 401 attached: true, |
| 402 detached: true, |
| 403 attributeChanged: true, |
| 404 ready: true |
| 405 }; |
358 Polymer.Base._addFeature({ | 406 Polymer.Base._addFeature({ |
359 _getExtendedPrototype: function (tag) { | 407 _getExtendedPrototype: function (tag) { |
360 return this._getExtendedNativePrototype(tag); | 408 return this._getExtendedNativePrototype(tag); |
361 }, | 409 }, |
362 _nativePrototypes: {}, | 410 _nativePrototypes: {}, |
363 _getExtendedNativePrototype: function (tag) { | 411 _getExtendedNativePrototype: function (tag) { |
364 var p = this._nativePrototypes[tag]; | 412 var p = this._nativePrototypes[tag]; |
365 if (!p) { | 413 if (!p) { |
366 var np = this.getNativePrototype(tag); | 414 var np = this.getNativePrototype(tag); |
367 p = this.extend(Object.create(np), Polymer.Base); | 415 p = this.extend(Object.create(np), Polymer.Base); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 } | 447 } |
400 return elt; | 448 return elt; |
401 } | 449 } |
402 }); | 450 }); |
403 Polymer.nob = Object.create(null); | 451 Polymer.nob = Object.create(null); |
404 Polymer.Base._addFeature({ | 452 Polymer.Base._addFeature({ |
405 properties: {}, | 453 properties: {}, |
406 getPropertyInfo: function (property) { | 454 getPropertyInfo: function (property) { |
407 var info = this._getPropertyInfo(property, this.properties); | 455 var info = this._getPropertyInfo(property, this.properties); |
408 if (!info) { | 456 if (!info) { |
409 this.behaviors.some(function (b) { | 457 for (var i = 0; i < this.behaviors.length; i++) { |
410 return info = this._getPropertyInfo(property, b.properties); | 458 info = this._getPropertyInfo(property, this.behaviors[i].properties); |
411 }, this); | 459 if (info) { |
| 460 return info; |
| 461 } |
| 462 } |
| 463 ; |
412 } | 464 } |
413 return info || Polymer.nob; | 465 return info || Polymer.nob; |
414 }, | 466 }, |
415 _getPropertyInfo: function (property, properties) { | 467 _getPropertyInfo: function (property, properties) { |
416 var p = properties && properties[property]; | 468 var p = properties && properties[property]; |
417 if (typeof p === 'function') { | 469 if (typeof p === 'function') { |
418 p = properties[property] = { type: p }; | 470 p = properties[property] = { type: p }; |
419 } | 471 } |
420 if (p) { | 472 if (p) { |
421 p.defined = true; | 473 p.defined = true; |
422 } | 474 } |
423 return p; | 475 return p; |
| 476 }, |
| 477 _prepPropertyInfo: function () { |
| 478 this._propertyInfo = {}; |
| 479 for (var i = 0, p; i < this.behaviors.length; i++) { |
| 480 this._addPropertyInfo(this._propertyInfo, this.behaviors[i].properties); |
| 481 } |
| 482 this._addPropertyInfo(this._propertyInfo, this.properties); |
| 483 this._addPropertyInfo(this._propertyInfo, this._propertyEffects); |
| 484 }, |
| 485 _addPropertyInfo: function (target, source) { |
| 486 if (source) { |
| 487 var t, s; |
| 488 for (var i in source) { |
| 489 t = target[i]; |
| 490 s = source[i]; |
| 491 if (i[0] === '_' && !s.readOnly) { |
| 492 continue; |
| 493 } |
| 494 if (!target[i]) { |
| 495 target[i] = { |
| 496 type: typeof s === 'function' ? s : s.type, |
| 497 readOnly: s.readOnly, |
| 498 attribute: Polymer.CaseMap.camelToDashCase(i) |
| 499 }; |
| 500 } else { |
| 501 if (!t.type) { |
| 502 t.type = s.type; |
| 503 } |
| 504 if (!t.readOnly) { |
| 505 t.readOnly = s.readOnly; |
| 506 } |
| 507 } |
| 508 } |
| 509 } |
424 } | 510 } |
425 }); | 511 }); |
426 Polymer.CaseMap = { | 512 Polymer.CaseMap = { |
427 _caseMap: {}, | 513 _caseMap: {}, |
428 dashToCamelCase: function (dash) { | 514 dashToCamelCase: function (dash) { |
429 var mapped = Polymer.CaseMap._caseMap[dash]; | 515 var mapped = Polymer.CaseMap._caseMap[dash]; |
430 if (mapped) { | 516 if (mapped) { |
431 return mapped; | 517 return mapped; |
432 } | 518 } |
433 if (dash.indexOf('-') < 0) { | 519 if (dash.indexOf('-') < 0) { |
434 return Polymer.CaseMap._caseMap[dash] = dash; | 520 return Polymer.CaseMap._caseMap[dash] = dash; |
435 } | 521 } |
436 return Polymer.CaseMap._caseMap[dash] = dash.replace(/-([a-z])/g, function (m) { | 522 return Polymer.CaseMap._caseMap[dash] = dash.replace(/-([a-z])/g, function (m) { |
437 return m[1].toUpperCase(); | 523 return m[1].toUpperCase(); |
438 }); | 524 }); |
439 }, | 525 }, |
440 camelToDashCase: function (camel) { | 526 camelToDashCase: function (camel) { |
441 var mapped = Polymer.CaseMap._caseMap[camel]; | 527 var mapped = Polymer.CaseMap._caseMap[camel]; |
442 if (mapped) { | 528 if (mapped) { |
443 return mapped; | 529 return mapped; |
444 } | 530 } |
445 return Polymer.CaseMap._caseMap[camel] = camel.replace(/([a-z][A-Z])/g, function
(g) { | 531 return Polymer.CaseMap._caseMap[camel] = camel.replace(/([a-z][A-Z])/g, function
(g) { |
446 return g[0] + '-' + g[1].toLowerCase(); | 532 return g[0] + '-' + g[1].toLowerCase(); |
447 }); | 533 }); |
448 } | 534 } |
449 }; | 535 }; |
450 Polymer.Base._addFeature({ | 536 Polymer.Base._addFeature({ |
451 _prepAttributes: function () { | 537 _addHostAttributes: function (attributes) { |
| 538 if (!this._aggregatedAttributes) { |
452 this._aggregatedAttributes = {}; | 539 this._aggregatedAttributes = {}; |
453 }, | 540 } |
454 _addHostAttributes: function (attributes) { | |
455 if (attributes) { | 541 if (attributes) { |
456 this.mixin(this._aggregatedAttributes, attributes); | 542 this.mixin(this._aggregatedAttributes, attributes); |
457 } | 543 } |
458 }, | 544 }, |
459 _marshalHostAttributes: function () { | 545 _marshalHostAttributes: function () { |
| 546 if (this._aggregatedAttributes) { |
460 this._applyAttributes(this, this._aggregatedAttributes); | 547 this._applyAttributes(this, this._aggregatedAttributes); |
| 548 } |
461 }, | 549 }, |
462 _applyAttributes: function (node, attr$) { | 550 _applyAttributes: function (node, attr$) { |
463 for (var n in attr$) { | 551 for (var n in attr$) { |
464 if (!this.hasAttribute(n) && n !== 'class') { | 552 if (!this.hasAttribute(n) && n !== 'class') { |
465 this.serializeValueToAttribute(attr$[n], n, this); | 553 var v = attr$[n]; |
| 554 this.serializeValueToAttribute(v, n, this); |
466 } | 555 } |
467 } | 556 } |
468 }, | 557 }, |
469 _marshalAttributes: function () { | 558 _marshalAttributes: function () { |
470 this._takeAttributesToModel(this); | 559 this._takeAttributesToModel(this); |
471 }, | 560 }, |
472 _takeAttributesToModel: function (model) { | 561 _takeAttributesToModel: function (model) { |
473 for (var i = 0, l = this.attributes.length; i < l; i++) { | 562 if (this.hasAttributes()) { |
474 this._setAttributeToProperty(model, this.attributes[i].name); | 563 for (var i in this._propertyInfo) { |
| 564 var info = this._propertyInfo[i]; |
| 565 if (this.hasAttribute(info.attribute)) { |
| 566 this._setAttributeToProperty(model, info.attribute, i, info); |
| 567 } |
| 568 } |
475 } | 569 } |
476 }, | 570 }, |
477 _setAttributeToProperty: function (model, attrName) { | 571 _setAttributeToProperty: function (model, attribute, property, info) { |
478 if (!this._serializing) { | 572 if (!this._serializing) { |
479 var propName = Polymer.CaseMap.dashToCamelCase(attrName); | 573 var property = property || Polymer.CaseMap.dashToCamelCase(attribute); |
480 var info = this.getPropertyInfo(propName); | 574 info = info || this._propertyInfo && this._propertyInfo[property]; |
481 if (info.defined || this._propertyEffects && this._propertyEffects[propName]) { | 575 if (info && !info.readOnly) { |
482 var val = this.getAttribute(attrName); | 576 var v = this.getAttribute(attribute); |
483 model[propName] = this.deserialize(val, info.type); | 577 model[property] = this.deserialize(v, info.type); |
484 } | 578 } |
485 } | 579 } |
486 }, | 580 }, |
487 _serializing: false, | 581 _serializing: false, |
488 reflectPropertyToAttribute: function (name) { | 582 reflectPropertyToAttribute: function (property, attribute, value) { |
489 this._serializing = true; | 583 this._serializing = true; |
490 this.serializeValueToAttribute(this[name], Polymer.CaseMap.camelToDashCase(name)
); | 584 value = value === undefined ? this[property] : value; |
| 585 this.serializeValueToAttribute(value, attribute || Polymer.CaseMap.camelToDashCa
se(property)); |
491 this._serializing = false; | 586 this._serializing = false; |
492 }, | 587 }, |
493 serializeValueToAttribute: function (value, attribute, node) { | 588 serializeValueToAttribute: function (value, attribute, node) { |
494 var str = this.serialize(value); | 589 var str = this.serialize(value); |
495 (node || this)[str === undefined ? 'removeAttribute' : 'setAttribute'](attribute
, str); | 590 node = node || this; |
| 591 if (str === undefined) { |
| 592 node.removeAttribute(attribute); |
| 593 } else { |
| 594 node.setAttribute(attribute, str); |
| 595 } |
496 }, | 596 }, |
497 deserialize: function (value, type) { | 597 deserialize: function (value, type) { |
498 switch (type) { | 598 switch (type) { |
499 case Number: | 599 case Number: |
500 value = Number(value); | 600 value = Number(value); |
501 break; | 601 break; |
502 case Boolean: | 602 case Boolean: |
503 value = value !== null; | 603 value = value !== null; |
504 break; | 604 break; |
505 case Object: | 605 case Object: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 debouncer.complete(); | 661 debouncer.complete(); |
562 } | 662 } |
563 }, | 663 }, |
564 cancelDebouncer: function (jobName) { | 664 cancelDebouncer: function (jobName) { |
565 var debouncer = this._debouncers[jobName]; | 665 var debouncer = this._debouncers[jobName]; |
566 if (debouncer) { | 666 if (debouncer) { |
567 debouncer.stop(); | 667 debouncer.stop(); |
568 } | 668 } |
569 } | 669 } |
570 }); | 670 }); |
571 Polymer.version = '1.2.1'; | 671 Polymer.version = '1.2.3'; |
572 Polymer.Base._addFeature({ | 672 Polymer.Base._addFeature({ |
573 _registerFeatures: function () { | 673 _registerFeatures: function () { |
574 this._prepIs(); | 674 this._prepIs(); |
575 this._prepAttributes(); | |
576 this._prepBehaviors(); | 675 this._prepBehaviors(); |
577 this._prepConstructor(); | 676 this._prepConstructor(); |
| 677 this._prepPropertyInfo(); |
578 }, | 678 }, |
579 _prepBehavior: function (b) { | 679 _prepBehavior: function (b) { |
580 this._addHostAttributes(b.hostAttributes); | 680 this._addHostAttributes(b.hostAttributes); |
581 }, | 681 }, |
582 _marshalBehavior: function (b) { | 682 _marshalBehavior: function (b) { |
583 }, | 683 }, |
584 _initFeatures: function () { | 684 _initFeatures: function () { |
585 this._marshalHostAttributes(); | 685 this._marshalHostAttributes(); |
586 this._setupDebouncers(); | 686 this._setupDebouncers(); |
587 this._marshalBehaviors(); | 687 this._marshalBehaviors(); |
588 } | 688 } |
589 }); | 689 }); |
OLD | NEW |