Do lazy behavior copying only when legacyOptimizations is set

This commit is contained in:
Steven Orvell
2018-11-09 18:48:53 -08:00
parent fbf827d9c7
commit 44e4828796
4 changed files with 20 additions and 5 deletions
+15 -3
View File
@@ -297,10 +297,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
`is` in `beforeRegister` as you could in 1.x.
*/
const proto = this;
if (behaviorList) {
applyBehaviors(proto, behaviorList, lifecycle);
// copy properties lazily if we're optimizing
if (Polymer.legacyOptimizations) {
copyPropertiesToProto(proto);
}
applyInfo(proto, info, lifecycle, excludeOnInfo);
let list = lifecycle.beforeRegister;
if (list) {
for (let i=0; i < list.length; i++) {
@@ -426,6 +426,18 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
superBehaviors.concat(behaviors) : behaviorList;
}
const copyPropertiesToProto = (proto) => {
if (behaviorList) {
applyBehaviors(proto, behaviorList, lifecycle);
}
applyInfo(proto, info, lifecycle, excludeOnInfo);
};
// copy properties if we're not optimizing
if (!Polymer.legacyOptimizations) {
copyPropertiesToProto(PolymerGenerated.prototype);
}
PolymerGenerated.generatedFrom = info;
return PolymerGenerated;