update polymer
This commit is contained in:
parent
2a830d2a3d
commit
6f8396a6e7
8 changed files with 106 additions and 57 deletions
|
@ -20,7 +20,7 @@ addEventListener('DOMContentLoaded', resolve);
|
|||
}
|
||||
}
|
||||
}());
|
||||
Polymer = {
|
||||
window.Polymer = {
|
||||
Settings: function () {
|
||||
var user = window.Polymer || {};
|
||||
location.search.slice(1).split('&').forEach(function (o) {
|
||||
|
@ -48,15 +48,21 @@ useNativeCustomElements: useNativeCustomElements
|
|||
(function () {
|
||||
var userPolymer = window.Polymer;
|
||||
window.Polymer = function (prototype) {
|
||||
var ctor = desugar(prototype);
|
||||
prototype = ctor.prototype;
|
||||
var options = { prototype: prototype };
|
||||
if (prototype.extends) {
|
||||
options.extends = prototype.extends;
|
||||
if (typeof prototype === 'function') {
|
||||
prototype = prototype.prototype;
|
||||
}
|
||||
if (!prototype) {
|
||||
prototype = {};
|
||||
}
|
||||
var factory = desugar(prototype);
|
||||
prototype = factory.prototype;
|
||||
var options = {
|
||||
prototype: prototype,
|
||||
extends: prototype.extends
|
||||
};
|
||||
Polymer.telemetry._registrate(prototype);
|
||||
document.registerElement(prototype.is, options);
|
||||
return ctor;
|
||||
return factory;
|
||||
};
|
||||
var desugar = function (prototype) {
|
||||
var base = Polymer.Base;
|
||||
|
@ -133,6 +139,8 @@ _addFeature: function (feature) {
|
|||
this.extend(this, feature);
|
||||
},
|
||||
registerCallback: function () {
|
||||
this._desugarBehaviors();
|
||||
this._doBehavior('beforeRegister');
|
||||
this._registerFeatures();
|
||||
this._doBehavior('registered');
|
||||
},
|
||||
|
@ -238,6 +246,7 @@ lcModules[id.toLowerCase()] = this;
|
|||
}
|
||||
},
|
||||
import: function (id, selector) {
|
||||
if (id) {
|
||||
var m = findModule(id);
|
||||
if (!m) {
|
||||
forceDocumentUpgrade();
|
||||
|
@ -248,6 +257,7 @@ m = m.querySelector(selector);
|
|||
}
|
||||
return m;
|
||||
}
|
||||
}
|
||||
});
|
||||
var cePolyfill = window.CustomElements && !CustomElements.useNative;
|
||||
document.registerElement('dom-module', DomModule);
|
||||
|
@ -255,8 +265,7 @@ function forceDocumentUpgrade() {
|
|||
if (cePolyfill) {
|
||||
var script = document._currentScript || document.currentScript;
|
||||
var doc = script && script.ownerDocument;
|
||||
if (doc && !doc.__customElementsForceUpgraded) {
|
||||
doc.__customElementsForceUpgraded = true;
|
||||
if (doc) {
|
||||
CustomElements.upgradeAll(doc);
|
||||
}
|
||||
}
|
||||
|
@ -278,11 +287,17 @@ 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 = [];
|
||||
|
@ -297,15 +312,6 @@ this._warn(this._logf('_flattenBehaviorsList', 'behavior is null, check for miss
|
|||
}, this);
|
||||
return flat;
|
||||
},
|
||||
_prepAllBehaviors: function (behaviors) {
|
||||
for (var i = behaviors.length - 1; i >= 0; i--) {
|
||||
this._mixinBehavior(behaviors[i]);
|
||||
}
|
||||
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) {
|
||||
|
@ -329,6 +335,15 @@ break;
|
|||
}
|
||||
}, 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);
|
||||
},
|
||||
_doBehavior: function (name, args) {
|
||||
this.behaviors.forEach(function (b) {
|
||||
this._invokeBehavior(b, name, args);
|
||||
|
@ -561,7 +576,7 @@ debouncer.stop();
|
|||
}
|
||||
}
|
||||
});
|
||||
Polymer.version = '1.1.1';
|
||||
Polymer.version = '1.1.2';
|
||||
Polymer.Base._addFeature({
|
||||
_registerFeatures: function () {
|
||||
this._prepIs();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue