Skip to content

Commit

Permalink
even more lazy: defer template lookup and style collection until fini…
Browse files Browse the repository at this point in the history
…sh register time.
  • Loading branch information
Steven Orvell committed Mar 17, 2016
1 parent d7a2baa commit 103f790
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
5 changes: 3 additions & 2 deletions polymer.html
Expand Up @@ -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();
Expand Down
23 changes: 10 additions & 13 deletions src/standard/styling.html
Expand Up @@ -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);
Expand Down

0 comments on commit 103f790

Please sign in to comment.