File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,7 +55,10 @@ export function inject(
5555 // stylesheet declared later wins by document order. Style elements appended
5656 // to the light DOM don't apply inside shadow roots, so for the shadow DOM
5757 // case we prepend the style element to the shadow root itself.
58- ( root instanceof ShadowRoot ? root : document . head ) . prepend ( styleEl ) ;
58+ ( typeof globalThis . ShadowRoot !== 'undefined' && root instanceof ShadowRoot
59+ ? root
60+ : document . head
61+ ) . prepend ( styleEl ) ;
5962}
6063
6164/**
Original file line number Diff line number Diff line change @@ -1134,7 +1134,10 @@ export class ConstantProvider {
11341134 styleEl . textContent = this . getCSS_ ( selector ) . join ( '\n' ) ;
11351135 // See css.ts inject() for the rationale on prepending and shadow root
11361136 // handling.
1137- ( root instanceof ShadowRoot ? root : document . head ) . prepend ( styleEl ) ;
1137+ ( typeof globalThis . ShadowRoot !== 'undefined' && root instanceof ShadowRoot
1138+ ? root
1139+ : document . head
1140+ ) . prepend ( styleEl ) ;
11381141
11391142 const sitesForSelector =
11401143 injectionSites . get ( selector ) ?? new WeakSet < Document | ShadowRoot > ( ) ;
You can’t perform that action at this time.
0 commit comments