@@ -83,17 +83,19 @@ export const attachStyles = (plt: d.PlatformApi, domApi: d.DomApi, cmpMeta: d.Co
8383 // and add the scope attribute to the host
8484
8585 // create the style id w/ the host element's mode
86- let styleId = cmpMeta . tagNameMeta + hostElm . mode ;
86+ let styleId = cmpMeta . tagNameMeta + ( _BUILD_ . hasMode ? hostElm . mode : DEFAULT_STYLE_MODE ) ;
8787 let styleTemplate = ( cmpMeta as any ) [ styleId ] ;
8888
89- const shouldScopeCss = ( cmpMeta . encapsulationMeta === ENCAPSULATION . ScopedCss || ( cmpMeta . encapsulationMeta === ENCAPSULATION . ShadowDom && ! plt . domApi . $supportsShadowDom ) ) ;
90- if ( shouldScopeCss ) {
91- hostElm [ 's-sc' ] = styleTemplate
92- ? getScopeId ( cmpMeta , hostElm . mode )
93- : getScopeId ( cmpMeta ) ;
94- }
89+ // if (_BUILD_.scoped || _BUILD_.shadowDom) {
90+ const shouldScopeCss = ( cmpMeta . encapsulationMeta === ENCAPSULATION . ScopedCss || ( cmpMeta . encapsulationMeta === ENCAPSULATION . ShadowDom && ! plt . domApi . $supportsShadowDom ) ) ;
91+ if ( shouldScopeCss ) {
92+ hostElm [ 's-sc' ] = styleTemplate
93+ ? getScopeId ( cmpMeta , hostElm . mode )
94+ : getScopeId ( cmpMeta ) ;
95+ }
96+ // }
9597
96- if ( ! styleTemplate ) {
98+ if ( _BUILD_ . hasMode && ! styleTemplate ) {
9799 // doesn't look like there's a style template with the mode
98100 // create the style id using the default style mode and try again
99101 styleId = cmpMeta . tagNameMeta + DEFAULT_STYLE_MODE ;
@@ -114,14 +116,9 @@ export const attachStyles = (plt: d.PlatformApi, domApi: d.DomApi, cmpMeta: d.Co
114116
115117 } else {
116118 // climb up the dom and see if we're in a shadow dom
117- let root : d . HostElement = hostElm ;
118- while ( root = domApi . $parentNode ( root ) as d . HostElement ) {
119- if ( root . host && root . host . shadowRoot ) {
120- // looks like we are in shadow dom, let's use
121- // this shadow root as the container for these styles
122- styleContainerNode = ( root . host . shadowRoot ) as any ;
123- break ;
124- }
119+ const rootEl = ( hostElm as any ) . getRootNode ( ) ;
120+ if ( rootEl . host ) {
121+ styleContainerNode = rootEl ;
125122 }
126123 }
127124 }
@@ -138,7 +135,7 @@ export const attachStyles = (plt: d.PlatformApi, domApi: d.DomApi, cmpMeta: d.Co
138135 if ( ! appliedStyles [ styleId ] ) {
139136 let styleElm : HTMLStyleElement ;
140137 if ( _BUILD_ . es5 ) {
141- // es5 builds are not usig <template> because of ie11 issues
138+ // es5 builds are not using <template> because of ie11 issues
142139 // instead the "template" is just the style text as a string
143140 // create a new style element and add as innerHTML
144141
0 commit comments