Skip to content

Commit 103f790

Browse files
author
Steven Orvell
committed
even more lazy: defer template lookup and style collection until finish register time.
1 parent d7a2baa commit 103f790

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

polymer.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@
3030
this._prepIs();
3131
// factory
3232
this._prepConstructor();
33-
// template
34-
this._prepTemplate();
3533
// styles
3634
this._prepStyles();
3735
},
3836

3937
_finishRegisterFeatures: function() {
38+
// template
39+
this._prepTemplate();
40+
// style shimming
4041
this._prepShimStyles();
4142
// template markup
4243
this._prepAnnotations();

src/standard/styling.html

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,21 @@
3636
},
3737

3838
_prepStyles: function() {
39-
if (this._encapsulateStyle === undefined) {
40-
this._encapsulateStyle = !nativeShadow &&
41-
Boolean(this._template);
42-
}
43-
if (this._template) {
44-
this._styles = this._collectStyles();
45-
// under shady dom we always output a shimmed style (which may be
46-
// empty) so that other dynamic stylesheets can always be placed
47-
// after the element's main stylesheet.
48-
// This helps ensure element styles are always in registration order.
49-
if (this._styles.length && !nativeShadow) {
50-
this._scopeStyle = styleUtil.applyStylePlaceHolder(this.is);
51-
}
39+
// under shady dom we always output a shimmed style (which may be
40+
// empty) so that other dynamic stylesheets can always be placed
41+
// after the element's main stylesheet.
42+
// This helps ensure element styles are always in registration order.
43+
if (!nativeShadow) {
44+
this._scopeStyle = styleUtil.applyStylePlaceHolder(this.is);
5245
}
5346
},
5447

5548
_prepShimStyles: function() {
5649
if (this._template) {
50+
if (this._encapsulateStyle === undefined) {
51+
this._encapsulateStyle = !nativeShadow;
52+
}
53+
this._styles = this._collectStyles();
5754
// calculate shimmed styles (we must always do this as it
5855
// stores shimmed style data in the css rules for later use)
5956
var cssText = styleTransformer.elementStyles(this);

0 commit comments

Comments
 (0)