Adds legacyOptimizations flag

Set using `Polymer.setLegacyOptimizations(true)`. This flag enables optimizaitons including, always stripping whitespace from templates and avoiding cloning element templates (assumes no inheritance is used)

Also re-enables dir-mixin.
This commit is contained in:
Steven Orvell
2018-10-30 18:15:25 -07:00
parent 7251a3acc2
commit 4f223035c3
4 changed files with 21 additions and 8 deletions
-1
View File
@@ -79,7 +79,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* @memberof Polymer
*/
Polymer.DirMixin = Polymer.dedupingMixin((base) => {
return base;
if (!observer) {
getRTL();
+4 -4
View File
@@ -314,8 +314,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
let t = document.createElement('template');
t.innerHTML = template;
template = t;
// } else {
// template = template.cloneNode(true);
} else if (!Polymer.legacyOptimizations) {
template = template.cloneNode(true);
}
}
@@ -409,7 +409,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* The `importPath` property is also set on element instances and can be
* used to create bindings relative to the import path.
*
* For elements defined in ES modules, users should implement
* For elements defined in ES modules, users should implement
* `static get importMeta() { return import.meta; }`, and the default
* implementation of `importPath` will return `import.meta.url`'s path.
* For elements defined in HTML imports, this getter will return the path
@@ -428,7 +428,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
this._importPath = Polymer.ResolveUrl.pathFromUrl(meta.url);
} else {
const module = Polymer.DomModule && Polymer.DomModule.import(/** @type {PolymerElementConstructor} */ (this).is);
this._importPath = (module && module.assetpath) ||
this._importPath = (module && module.assetpath) ||
Object.getPrototypeOf(/** @type {PolymerElementConstructor}*/ (this).prototype).constructor.importPath;
}
}
+3 -3
View File
@@ -203,9 +203,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
if (!template._templateInfo) {
let templateInfo = template._templateInfo = {};
templateInfo.nodeInfoList = [];
templateInfo.stripWhiteSpace = true;
// (outerTemplateInfo && outerTemplateInfo.stripWhiteSpace) ||
// template.hasAttribute('strip-whitespace');
templateInfo.stripWhiteSpace = Polymer.legacyOptimizations ||
(outerTemplateInfo && outerTemplateInfo.stripWhiteSpace) ||
template.hasAttribute('strip-whitespace');
this._parseTemplateContent(template, templateInfo, {parent: null});
}
return template._templateInfo;
+14
View File
@@ -114,5 +114,19 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
Polymer.setPassiveTouchGestures = function(usePassive) {
Polymer.passiveTouchGestures = usePassive;
};
let legacyOptimizations = false;
Polymer.legacyOptimizations = legacyOptimizations;
/**
* Sets `legacyOptimizations` globally for all elements. Enables
* optimizations when only legacy Polymer() style elements are used.
*
* @memberof Polymer
* @param {boolean} useLegacyOptimizations enable or disable legacy optimizations globally.
* @return {void}
*/
Polymer.setLegacyOptimizations = function(useLegacyOptimizations) {
Polymer.legacyOptimizations = useLegacyOptimizations;
};
})();
</script>