mirror of
https://github.com/Polymer/polymer.git
synced 2026-08-19 01:14:44 -05:00
Do lazy behavior copying only when legacyOptimizations is set
This commit is contained in:
+15
-3
@@ -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;
|
||||
|
||||
+2
-1
@@ -55,6 +55,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
'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',
|
||||
@@ -87,7 +88,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
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), []);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
<script>
|
||||
HTMLImports.whenReady(function() {
|
||||
|
||||
Polymer.setLegacyOptimizations(Boolean(window.location.search.match('legacyOptimizations')));
|
||||
|
||||
window.BehaviorA = {
|
||||
properties: {
|
||||
|
||||
|
||||
@@ -1058,7 +1058,6 @@ HTMLImports.whenReady(function() {
|
||||
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'));
|
||||
|
||||
Reference in New Issue
Block a user