mirror of
https://github.com/Polymer/polymer.git
synced 2026-08-19 01:14:44 -05:00
lazyCopyProps
This commit is contained in:
+21
-17
@@ -63,7 +63,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
return GenerateClassFromInfo({}, klass);
|
||||
}
|
||||
|
||||
|
||||
function applyBehaviors(behaviors, klass) {
|
||||
if (!behaviors) {
|
||||
klass = /** @type {HTMLElement} */(klass); // eslint-disable-line no-self-assign
|
||||
@@ -72,7 +71,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
// NOTE: ensure the behavior is extending a class with
|
||||
// legacy element api. This is necessary since behaviors expect to be able
|
||||
// to access 1.x legacy api.
|
||||
klass = class extends Polymer.LegacyElementMixin(klass) {};
|
||||
klass = class extends Polymer.LegacyElementMixin(klass) { };
|
||||
if (!Array.isArray(behaviors)) {
|
||||
behaviors = [behaviors];
|
||||
}
|
||||
@@ -80,7 +79,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
// get flattened, deduped list of behaviors *not* already on super class
|
||||
behaviors = flattenBehaviors(behaviors, null, superBehaviors);
|
||||
// mixin new behaviors
|
||||
klass = _applyBehaviors(behaviors, klass);
|
||||
// klass = _applyBehaviors(behaviors, klass);
|
||||
if (superBehaviors) {
|
||||
behaviors = superBehaviors.concat(behaviors);
|
||||
}
|
||||
@@ -120,14 +119,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
// (1) C.created, (2) A.created, (3) B.created, (4) element.created
|
||||
// (again same as 1.x)
|
||||
function _applyBehaviors(behaviors, klass) {
|
||||
for (let i=0; i<behaviors.length; i++) {
|
||||
let b = behaviors[i];
|
||||
if (b) {
|
||||
Array.isArray(b) ? _applyBehaviors(b, klass) :
|
||||
copyProperties(b, klass.prototype);
|
||||
if (behaviors) {
|
||||
for (let i=0; i<behaviors.length; i++) {
|
||||
let b = behaviors[i];
|
||||
// if (b) {
|
||||
// Array.isArray(b) ? _applyBehaviors(b, klass) :
|
||||
copyProperties(b, klass.prototype);
|
||||
// }
|
||||
}
|
||||
return klass;
|
||||
}
|
||||
return klass;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,22 +287,25 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
in `beforeRegister` or `registered`. It is no longer possible to set
|
||||
`is` in `beforeRegister` as you could in 1.x.
|
||||
*/
|
||||
if (this.behaviors) {
|
||||
for (let i=0, b; i < this.behaviors.length; i++) {
|
||||
b = this.behaviors[i];
|
||||
const proto = Object.getPrototypeOf(this);
|
||||
_applyBehaviors(proto.behaviors, proto.constructor);
|
||||
copyProperties(info, proto);
|
||||
if (proto.behaviors) {
|
||||
for (let i=0, b; i < proto.behaviors.length; i++) {
|
||||
b = proto.behaviors[i];
|
||||
if (b.beforeRegister) {
|
||||
b.beforeRegister.call(Object.getPrototypeOf(this));
|
||||
b.beforeRegister.call(proto);
|
||||
}
|
||||
if (b.registered) {
|
||||
b.registered.call(Object.getPrototypeOf(this));
|
||||
b.registered.call(proto);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (info.beforeRegister) {
|
||||
info.beforeRegister.call(Object.getPrototypeOf(this));
|
||||
info.beforeRegister.call(proto);
|
||||
}
|
||||
if (info.registered) {
|
||||
info.registered.call(Object.getPrototypeOf(this));
|
||||
info.registered.call(proto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,7 +432,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
PolymerGenerated.generatedFrom = info;
|
||||
|
||||
copyProperties(info, PolymerGenerated.prototype);
|
||||
// copyProperties(info, PolymerGenerated.prototype);
|
||||
|
||||
return PolymerGenerated;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user