Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/blockly/core/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ export function inject(
// stylesheet declared later wins by document order. Style elements appended
// to the light DOM don't apply inside shadow roots, so for the shadow DOM
// case we prepend the style element to the shadow root itself.
(root instanceof ShadowRoot ? root : document.head).prepend(styleEl);
(typeof globalThis.ShadowRoot !== 'undefined' && root instanceof ShadowRoot
? root
: document.head
).prepend(styleEl);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion packages/blockly/core/renderers/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,10 @@ export class ConstantProvider {
styleEl.textContent = this.getCSS_(selector).join('\n');
// See css.ts inject() for the rationale on prepending and shadow root
// handling.
(root instanceof ShadowRoot ? root : document.head).prepend(styleEl);
(typeof globalThis.ShadowRoot !== 'undefined' && root instanceof ShadowRoot
? root
: document.head
).prepend(styleEl);

const sitesForSelector =
injectionSites.get(selector) ?? new WeakSet<Document | ShadowRoot>();
Expand Down
Loading