diff --git a/lib/mixins/dir-mixin.html b/lib/mixins/dir-mixin.html index 42ff09ade3..c029ed3e37 100644 --- a/lib/mixins/dir-mixin.html +++ b/lib/mixins/dir-mixin.html @@ -79,7 +79,6 @@ * @memberof Polymer */ Polymer.DirMixin = Polymer.dedupingMixin((base) => { - return base; if (!observer) { getRTL(); diff --git a/lib/mixins/element-mixin.html b/lib/mixins/element-mixin.html index 8187decfc1..3a0f3b7fad 100644 --- a/lib/mixins/element-mixin.html +++ b/lib/mixins/element-mixin.html @@ -314,8 +314,8 @@ 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 @@ * 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 @@ 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; } } diff --git a/lib/mixins/template-stamp.html b/lib/mixins/template-stamp.html index 9927c16dde..da679f742f 100644 --- a/lib/mixins/template-stamp.html +++ b/lib/mixins/template-stamp.html @@ -203,9 +203,9 @@ 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; diff --git a/lib/utils/settings.html b/lib/utils/settings.html index 5b0dc42039..b882a194ae 100644 --- a/lib/utils/settings.html +++ b/lib/utils/settings.html @@ -114,5 +114,19 @@ 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; + }; })();