From 103f7902a3f4d757129230591fbb019861e7aa7f Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Wed, 16 Mar 2016 19:02:24 -0700 Subject: [PATCH] even more lazy: defer template lookup and style collection until finish register time. --- polymer.html | 5 +++-- src/standard/styling.html | 23 ++++++++++------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/polymer.html b/polymer.html index 21078653d7..1ab47eac4a 100644 --- a/polymer.html +++ b/polymer.html @@ -30,13 +30,14 @@ this._prepIs(); // factory this._prepConstructor(); - // template - this._prepTemplate(); // styles this._prepStyles(); }, _finishRegisterFeatures: function() { + // template + this._prepTemplate(); + // style shimming this._prepShimStyles(); // template markup this._prepAnnotations(); diff --git a/src/standard/styling.html b/src/standard/styling.html index 60fb7ce910..db0321a0f1 100644 --- a/src/standard/styling.html +++ b/src/standard/styling.html @@ -36,24 +36,21 @@ }, _prepStyles: function() { - if (this._encapsulateStyle === undefined) { - this._encapsulateStyle = !nativeShadow && - Boolean(this._template); - } - if (this._template) { - this._styles = this._collectStyles(); - // under shady dom we always output a shimmed style (which may be - // empty) so that other dynamic stylesheets can always be placed - // after the element's main stylesheet. - // This helps ensure element styles are always in registration order. - if (this._styles.length && !nativeShadow) { - this._scopeStyle = styleUtil.applyStylePlaceHolder(this.is); - } + // under shady dom we always output a shimmed style (which may be + // empty) so that other dynamic stylesheets can always be placed + // after the element's main stylesheet. + // This helps ensure element styles are always in registration order. + if (!nativeShadow) { + this._scopeStyle = styleUtil.applyStylePlaceHolder(this.is); } }, _prepShimStyles: function() { if (this._template) { + if (this._encapsulateStyle === undefined) { + this._encapsulateStyle = !nativeShadow; + } + this._styles = this._collectStyles(); // calculate shimmed styles (we must always do this as it // stores shimmed style data in the css rules for later use) var cssText = styleTransformer.elementStyles(this);