diff --git a/lib/legacy/class.js b/lib/legacy/class.js index afe69ead11..55a3cf11da 100644 --- a/lib/legacy/class.js +++ b/lib/legacy/class.js @@ -9,6 +9,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN */ import { LegacyElementMixin } from './legacy-element-mixin.js'; +import { legacyOptimizations } from '../utils/settings.js'; const lifecycleProps = { attached: true, @@ -293,10 +294,10 @@ function GenerateClassFromInfo(info, Base, behaviors) { `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 (legacyOptimizations) { + copyPropertiesToProto(proto); } - applyInfo(proto, info, lifecycle, excludeOnInfo); let list = lifecycle.beforeRegister; if (list) { for (let i=0; i < list.length; i++) { @@ -422,6 +423,18 @@ function GenerateClassFromInfo(info, Base, behaviors) { 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 (!legacyOptimizations) { + copyPropertiesToProto(PolymerGenerated.prototype); + } + PolymerGenerated.generatedFrom = info; return PolymerGenerated; diff --git a/test/runner.html b/test/runner.html index 13e6e66773..e1061780ae 100644 --- a/test/runner.html +++ b/test/runner.html @@ -56,6 +56,7 @@ 'unit/attributes.html', 'unit/async.html', 'unit/behaviors.html', + 'unit/behaviors.html?legacyOptimizations=true', 'unit/polymer.element.html', 'unit/polymer.properties-mixin.html', 'unit/polymer.properties-mixin-with-property-accessors.html', @@ -89,7 +90,7 @@ function combinations(suites, flags) { return flags.map((f) => { - return f ? suites.map(s => `${s}?${f}`) : suites; + return f ? suites.map(s => `${s}${s.match(/\?/) ? '&' : '?'}${f}`) : suites; }).reduce((arr, s) => arr.concat(s), []); } diff --git a/test/unit/behaviors.html b/test/unit/behaviors.html index 61de81d601..7bd725b269 100644 --- a/test/unit/behaviors.html +++ b/test/unit/behaviors.html @@ -14,6 +14,10 @@ + diff --git a/test/unit/styling-scoped.html b/test/unit/styling-scoped.html index 227de37ce0..ae9d81b95f 100644 --- a/test/unit/styling-scoped.html +++ b/test/unit/styling-scoped.html @@ -1009,7 +1009,6 @@ var e = document.createElement('x-class-literal'); document.body.appendChild(e); var el = e.$.scope; - assert.equal(el.classList.length, 4); assert.isTrue(el.classList.contains('a')); assert.isTrue(el.classList.contains('c')); assert.isTrue(el.classList.contains('d'));