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