Index: polymer_1.2.3/bower_components/polymer/polymer-micro.html |
diff --git a/polymer_1.0.4/bower_components/polymer/polymer-micro.html b/polymer_1.2.3/bower_components/polymer/polymer-micro.html |
similarity index 60% |
copy from polymer_1.0.4/bower_components/polymer/polymer-micro.html |
copy to polymer_1.2.3/bower_components/polymer/polymer-micro.html |
index e16f5b17a6d546f7c733c20ff67574a18655f3cf..9b82929afcbc54da49c56820fea5183cbae35c2e 100644 |
--- a/polymer_1.0.4/bower_components/polymer/polymer-micro.html |
+++ b/polymer_1.2.3/bower_components/polymer/polymer-micro.html |
@@ -20,13 +20,14 @@ addEventListener('DOMContentLoaded', resolve); |
} |
} |
}()); |
-Polymer = { |
+window.Polymer = { |
Settings: function () { |
var user = window.Polymer || {}; |
-location.search.slice(1).split('&').forEach(function (o) { |
+var parts = location.search.slice(1).split('&'); |
+for (var i = 0, o; i < parts.length && (o = parts[i]); i++) { |
o = o.split('='); |
o[0] && (user[o[0]] = o[1] || true); |
-}); |
+} |
var wantShadow = user.dom === 'shadow'; |
var hasShadow = Boolean(Element.prototype.createShadowRoot); |
var nativeShadow = hasShadow && !window.ShadowDOMPolyfill; |
@@ -48,18 +49,28 @@ useNativeCustomElements: useNativeCustomElements |
(function () { |
var userPolymer = window.Polymer; |
window.Polymer = function (prototype) { |
-var ctor = desugar(prototype); |
-prototype = ctor.prototype; |
+if (typeof prototype === 'function') { |
+prototype = prototype.prototype; |
+} |
+if (!prototype) { |
+prototype = {}; |
+} |
+var factory = desugar(prototype); |
+prototype = factory.prototype; |
var options = { prototype: prototype }; |
if (prototype.extends) { |
options.extends = prototype.extends; |
} |
Polymer.telemetry._registrate(prototype); |
document.registerElement(prototype.is, options); |
-return ctor; |
+return factory; |
}; |
var desugar = function (prototype) { |
-prototype = Polymer.Base.chainObject(prototype, Polymer.Base); |
+var base = Polymer.Base; |
+if (prototype.extends) { |
+base = Polymer.Base._getExtendedPrototype(prototype.extends); |
+} |
+prototype = Polymer.Base.chainObject(prototype, base); |
prototype.registerCallback(); |
return prototype.constructor; |
}; |
@@ -91,11 +102,84 @@ get: function () { |
return (document._currentScript || document.currentScript).ownerDocument; |
} |
}); |
+Polymer.RenderStatus = { |
+_ready: false, |
+_callbacks: [], |
+whenReady: function (cb) { |
+if (this._ready) { |
+cb(); |
+} else { |
+this._callbacks.push(cb); |
+} |
+}, |
+_makeReady: function () { |
+this._ready = true; |
+for (var i = 0; i < this._callbacks.length; i++) { |
+this._callbacks[i](); |
+} |
+this._callbacks = []; |
+}, |
+_catchFirstRender: function () { |
+requestAnimationFrame(function () { |
+Polymer.RenderStatus._makeReady(); |
+}); |
+}, |
+_afterNextRenderQueue: [], |
+_waitingNextRender: false, |
+afterNextRender: function (element, fn, args) { |
+this._watchNextRender(); |
+this._afterNextRenderQueue.push([ |
+element, |
+fn, |
+args |
+]); |
+}, |
+_watchNextRender: function () { |
+if (!this._waitingNextRender) { |
+this._waitingNextRender = true; |
+var fn = function () { |
+Polymer.RenderStatus._flushNextRender(); |
+}; |
+if (!this._ready) { |
+this.whenReady(fn); |
+} else { |
+requestAnimationFrame(fn); |
+} |
+} |
+}, |
+_flushNextRender: function () { |
+var self = this; |
+setTimeout(function () { |
+self._flushRenderCallbacks(self._afterNextRenderQueue); |
+self._afterNextRenderQueue = []; |
+self._waitingNextRender = false; |
+}); |
+}, |
+_flushRenderCallbacks: function (callbacks) { |
+for (var i = 0, h; i < callbacks.length; i++) { |
+h = callbacks[i]; |
+h[1].apply(h[0], h[2] || Polymer.nar); |
+} |
+; |
+} |
+}; |
+if (window.HTMLImports) { |
+HTMLImports.whenReady(function () { |
+Polymer.RenderStatus._catchFirstRender(); |
+}); |
+} else { |
+Polymer.RenderStatus._catchFirstRender(); |
+} |
+Polymer.ImportStatus = Polymer.RenderStatus; |
+Polymer.ImportStatus.whenLoaded = Polymer.ImportStatus.whenReady; |
Polymer.Base = { |
+__isPolymerInstance__: true, |
_addFeature: function (feature) { |
this.extend(this, feature); |
}, |
registerCallback: function () { |
+this._desugarBehaviors(); |
+this._doBehavior('beforeRegister'); |
this._registerFeatures(); |
this._doBehavior('registered'); |
}, |
@@ -106,25 +190,42 @@ this._doBehavior('created'); |
this._initFeatures(); |
}, |
attachedCallback: function () { |
-this.isAttached = true; |
-this._doBehavior('attached'); |
+var self = this; |
+Polymer.RenderStatus.whenReady(function () { |
+self.isAttached = true; |
+self._doBehavior('attached'); |
+}); |
}, |
detachedCallback: function () { |
this.isAttached = false; |
this._doBehavior('detached'); |
}, |
-attributeChangedCallback: function (name) { |
+attributeChangedCallback: function (name, oldValue, newValue) { |
+this._attributeChangedImpl(name); |
+this._doBehavior('attributeChanged', [ |
+name, |
+oldValue, |
+newValue |
+]); |
+}, |
+_attributeChangedImpl: function (name) { |
this._setAttributeToProperty(this, name); |
-this._doBehavior('attributeChanged', arguments); |
}, |
extend: function (prototype, api) { |
if (prototype && api) { |
-Object.getOwnPropertyNames(api).forEach(function (n) { |
+var n$ = Object.getOwnPropertyNames(api); |
+for (var i = 0, n; i < n$.length && (n = n$[i]); i++) { |
this.copyOwnProperty(n, api, prototype); |
-}, this); |
+} |
} |
return prototype || api; |
}, |
+mixin: function (target, source) { |
+for (var i in source) { |
+target[i] = source[i]; |
+} |
+return target; |
+}, |
copyOwnProperty: function (name, source, target) { |
var pd = Object.getOwnPropertyDescriptor(source, name); |
if (pd) { |
@@ -155,46 +256,67 @@ object.__proto__ = inherited; |
return object; |
}; |
Polymer.Base = Polymer.Base.chainObject(Polymer.Base, HTMLElement.prototype); |
+if (window.CustomElements) { |
+Polymer.instanceof = CustomElements.instanceof; |
+} else { |
+Polymer.instanceof = function (obj, ctor) { |
+return obj instanceof ctor; |
+}; |
+} |
+Polymer.isInstance = function (obj) { |
+return Boolean(obj && obj.__isPolymerInstance__); |
+}; |
Polymer.telemetry.instanceCount = 0; |
(function () { |
var modules = {}; |
+var lcModules = {}; |
+var findModule = function (id) { |
+return modules[id] || lcModules[id.toLowerCase()]; |
+}; |
var DomModule = function () { |
return document.createElement('dom-module'); |
}; |
DomModule.prototype = Object.create(HTMLElement.prototype); |
-DomModule.prototype.constructor = DomModule; |
-DomModule.prototype.createdCallback = function () { |
-var id = this.id || this.getAttribute('name') || this.getAttribute('is'); |
+Polymer.Base.extend(DomModule.prototype, { |
+constructor: DomModule, |
+createdCallback: function () { |
+this.register(); |
+}, |
+register: function (id) { |
+var id = id || this.id || this.getAttribute('name') || this.getAttribute('is'); |
if (id) { |
this.id = id; |
modules[id] = this; |
+lcModules[id.toLowerCase()] = this; |
} |
-}; |
-DomModule.prototype.import = function (id, slctr) { |
-var m = modules[id]; |
+}, |
+import: function (id, selector) { |
+if (id) { |
+var m = findModule(id); |
if (!m) { |
-forceDocumentUpgrade(); |
-m = modules[id]; |
+forceDomModulesUpgrade(); |
+m = findModule(id); |
} |
-if (m && slctr) { |
-m = m.querySelector(slctr); |
+if (m && selector) { |
+m = m.querySelector(selector); |
} |
return m; |
-}; |
-var cePolyfill = window.CustomElements && !CustomElements.useNative; |
-if (cePolyfill) { |
-var ready = CustomElements.ready; |
-CustomElements.ready = true; |
} |
-document.registerElement('dom-module', DomModule); |
-if (cePolyfill) { |
-CustomElements.ready = ready; |
} |
-function forceDocumentUpgrade() { |
+}); |
+var cePolyfill = window.CustomElements && !CustomElements.useNative; |
+document.registerElement('dom-module', DomModule); |
+function forceDomModulesUpgrade() { |
if (cePolyfill) { |
var script = document._currentScript || document.currentScript; |
-if (script) { |
-CustomElements.upgradeAll(script.ownerDocument); |
+var doc = script && script.ownerDocument || document; |
+var modules = doc.querySelectorAll('dom-module'); |
+for (var i = modules.length - 1, m; i >= 0 && (m = modules[i]); i--) { |
+if (m.__upgraded__) { |
+return; |
+} else { |
+CustomElements.upgrade(m); |
+} |
} |
} |
} |
@@ -208,19 +330,29 @@ var id = module.id || module.getAttribute('name') || module.getAttribute('is'); |
this.is = id; |
} |
} |
+if (this.is) { |
+this.is = this.is.toLowerCase(); |
+} |
} |
}); |
Polymer.Base._addFeature({ |
behaviors: [], |
-_prepBehaviors: function () { |
+_desugarBehaviors: function () { |
if (this.behaviors.length) { |
-this.behaviors = this._flattenBehaviorsList(this.behaviors); |
+this.behaviors = this._desugarSomeBehaviors(this.behaviors); |
} |
-this._prepAllBehaviors(this.behaviors); |
+}, |
+_desugarSomeBehaviors: function (behaviors) { |
+behaviors = this._flattenBehaviorsList(behaviors); |
+for (var i = behaviors.length - 1; i >= 0; i--) { |
+this._mixinBehavior(behaviors[i]); |
+} |
+return behaviors; |
}, |
_flattenBehaviorsList: function (behaviors) { |
var flat = []; |
-behaviors.forEach(function (b) { |
+for (var i = 0; i < behaviors.length; i++) { |
+var b = behaviors[i]; |
if (b instanceof Array) { |
flat = flat.concat(this._flattenBehaviorsList(b)); |
} else if (b) { |
@@ -228,45 +360,30 @@ flat.push(b); |
} else { |
this._warn(this._logf('_flattenBehaviorsList', 'behavior is null, check for missing or 404 import')); |
} |
-}, this); |
+} |
return flat; |
}, |
-_prepAllBehaviors: function (behaviors) { |
-for (var i = behaviors.length - 1; i >= 0; i--) { |
-this._mixinBehavior(behaviors[i]); |
+_mixinBehavior: function (b) { |
+var n$ = Object.getOwnPropertyNames(b); |
+for (var i = 0, n; i < n$.length && (n = n$[i]); i++) { |
+if (!Polymer.Base._behaviorProperties[n] && !this.hasOwnProperty(n)) { |
+this.copyOwnProperty(n, b, this); |
} |
+} |
+}, |
+_prepBehaviors: function () { |
+this._prepFlattenedBehaviors(this.behaviors); |
+}, |
+_prepFlattenedBehaviors: function (behaviors) { |
for (var i = 0, l = behaviors.length; i < l; i++) { |
this._prepBehavior(behaviors[i]); |
} |
this._prepBehavior(this); |
}, |
-_mixinBehavior: function (b) { |
-Object.getOwnPropertyNames(b).forEach(function (n) { |
-switch (n) { |
-case 'hostAttributes': |
-case 'registered': |
-case 'properties': |
-case 'observers': |
-case 'listeners': |
-case 'created': |
-case 'attached': |
-case 'detached': |
-case 'attributeChanged': |
-case 'configure': |
-case 'ready': |
-break; |
-default: |
-if (!this.hasOwnProperty(n)) { |
-this.copyOwnProperty(n, b, this); |
-} |
-break; |
-} |
-}, this); |
-}, |
_doBehavior: function (name, args) { |
-this.behaviors.forEach(function (b) { |
-this._invokeBehavior(b, name, args); |
-}, this); |
+for (var i = 0; i < this.behaviors.length; i++) { |
+this._invokeBehavior(this.behaviors[i], name, args); |
+} |
this._invokeBehavior(this, name, args); |
}, |
_invokeBehavior: function (b, name, args) { |
@@ -276,18 +393,25 @@ fn.apply(this, args || Polymer.nar); |
} |
}, |
_marshalBehaviors: function () { |
-this.behaviors.forEach(function (b) { |
-this._marshalBehavior(b); |
-}, this); |
+for (var i = 0; i < this.behaviors.length; i++) { |
+this._marshalBehavior(this.behaviors[i]); |
+} |
this._marshalBehavior(this); |
} |
}); |
+Polymer.Base._behaviorProperties = { |
+hostAttributes: true, |
+registered: true, |
+properties: true, |
+observers: true, |
+listeners: true, |
+created: true, |
+attached: true, |
+detached: true, |
+attributeChanged: true, |
+ready: true |
+}; |
Polymer.Base._addFeature({ |
-_prepExtends: function () { |
-if (this.extends) { |
-this.__proto__ = this._getExtendedPrototype(this.extends); |
-} |
-}, |
_getExtendedPrototype: function (tag) { |
return this._getExtendedNativePrototype(tag); |
}, |
@@ -338,9 +462,13 @@ properties: {}, |
getPropertyInfo: function (property) { |
var info = this._getPropertyInfo(property, this.properties); |
if (!info) { |
-this.behaviors.some(function (b) { |
-return info = this._getPropertyInfo(property, b.properties); |
-}, this); |
+for (var i = 0; i < this.behaviors.length; i++) { |
+info = this._getPropertyInfo(property, this.behaviors[i].properties); |
+if (info) { |
+return info; |
+} |
+} |
+; |
} |
return info || Polymer.nob; |
}, |
@@ -353,6 +481,40 @@ if (p) { |
p.defined = true; |
} |
return p; |
+}, |
+_prepPropertyInfo: function () { |
+this._propertyInfo = {}; |
+for (var i = 0, p; i < this.behaviors.length; i++) { |
+this._addPropertyInfo(this._propertyInfo, this.behaviors[i].properties); |
+} |
+this._addPropertyInfo(this._propertyInfo, this.properties); |
+this._addPropertyInfo(this._propertyInfo, this._propertyEffects); |
+}, |
+_addPropertyInfo: function (target, source) { |
+if (source) { |
+var t, s; |
+for (var i in source) { |
+t = target[i]; |
+s = source[i]; |
+if (i[0] === '_' && !s.readOnly) { |
+continue; |
+} |
+if (!target[i]) { |
+target[i] = { |
+type: typeof s === 'function' ? s : s.type, |
+readOnly: s.readOnly, |
+attribute: Polymer.CaseMap.camelToDashCase(i) |
+}; |
+} else { |
+if (!t.type) { |
+t.type = s.type; |
+} |
+if (!t.readOnly) { |
+t.readOnly = s.readOnly; |
+} |
+} |
+} |
+} |
} |
}); |
Polymer.CaseMap = { |
@@ -380,21 +542,24 @@ return g[0] + '-' + g[1].toLowerCase(); |
} |
}; |
Polymer.Base._addFeature({ |
-_prepAttributes: function () { |
-this._aggregatedAttributes = {}; |
-}, |
_addHostAttributes: function (attributes) { |
+if (!this._aggregatedAttributes) { |
+this._aggregatedAttributes = {}; |
+} |
if (attributes) { |
this.mixin(this._aggregatedAttributes, attributes); |
} |
}, |
_marshalHostAttributes: function () { |
+if (this._aggregatedAttributes) { |
this._applyAttributes(this, this._aggregatedAttributes); |
+} |
}, |
_applyAttributes: function (node, attr$) { |
for (var n in attr$) { |
if (!this.hasAttribute(n) && n !== 'class') { |
-this.serializeValueToAttribute(attr$[n], n, this); |
+var v = attr$[n]; |
+this.serializeValueToAttribute(v, n, this); |
} |
} |
}, |
@@ -402,29 +567,40 @@ _marshalAttributes: function () { |
this._takeAttributesToModel(this); |
}, |
_takeAttributesToModel: function (model) { |
-for (var i = 0, l = this.attributes.length; i < l; i++) { |
-this._setAttributeToProperty(model, this.attributes[i].name); |
+if (this.hasAttributes()) { |
+for (var i in this._propertyInfo) { |
+var info = this._propertyInfo[i]; |
+if (this.hasAttribute(info.attribute)) { |
+this._setAttributeToProperty(model, info.attribute, i, info); |
+} |
+} |
} |
}, |
-_setAttributeToProperty: function (model, attrName) { |
+_setAttributeToProperty: function (model, attribute, property, info) { |
if (!this._serializing) { |
-var propName = Polymer.CaseMap.dashToCamelCase(attrName); |
-var info = this.getPropertyInfo(propName); |
-if (info.defined || this._propertyEffects && this._propertyEffects[propName]) { |
-var val = this.getAttribute(attrName); |
-model[propName] = this.deserialize(val, info.type); |
+var property = property || Polymer.CaseMap.dashToCamelCase(attribute); |
+info = info || this._propertyInfo && this._propertyInfo[property]; |
+if (info && !info.readOnly) { |
+var v = this.getAttribute(attribute); |
+model[property] = this.deserialize(v, info.type); |
} |
} |
}, |
_serializing: false, |
-reflectPropertyToAttribute: function (name) { |
+reflectPropertyToAttribute: function (property, attribute, value) { |
this._serializing = true; |
-this.serializeValueToAttribute(this[name], Polymer.CaseMap.camelToDashCase(name)); |
+value = value === undefined ? this[property] : value; |
+this.serializeValueToAttribute(value, attribute || Polymer.CaseMap.camelToDashCase(property)); |
this._serializing = false; |
}, |
serializeValueToAttribute: function (value, attribute, node) { |
var str = this.serialize(value); |
-(node || this)[str === undefined ? 'removeAttribute' : 'setAttribute'](attribute, str); |
+node = node || this; |
+if (str === undefined) { |
+node.removeAttribute(attribute); |
+} else { |
+node.setAttribute(attribute, str); |
+} |
}, |
deserialize: function (value, type) { |
switch (type) { |
@@ -481,7 +657,7 @@ _setupDebouncers: function () { |
this._debouncers = {}; |
}, |
debounce: function (jobName, callback, wait) { |
-this._debouncers[jobName] = Polymer.Debounce.call(this, this._debouncers[jobName], callback, wait); |
+return this._debouncers[jobName] = Polymer.Debounce.call(this, this._debouncers[jobName], callback, wait); |
}, |
isDebouncerActive: function (jobName) { |
var debouncer = this._debouncers[jobName]; |
@@ -500,14 +676,13 @@ debouncer.stop(); |
} |
} |
}); |
-Polymer.version = '1.0.4'; |
+Polymer.version = '1.2.3'; |
Polymer.Base._addFeature({ |
_registerFeatures: function () { |
this._prepIs(); |
-this._prepAttributes(); |
this._prepBehaviors(); |
-this._prepExtends(); |
this._prepConstructor(); |
+this._prepPropertyInfo(); |
}, |
_prepBehavior: function (b) { |
this._addHostAttributes(b.hostAttributes); |