From 0ffe68c2d310dc4b4f42c9c57f8c569848cd7a57 Mon Sep 17 00:00:00 2001 From: Sam Ottenhoff Date: Fri, 6 Dec 2024 19:13:07 +0100 Subject: [PATCH] SAK-50741 Webcomponents fix Chrome warning import rules are not allowed here (#13090) --- .../packages/sakai-element/src/global-styles.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/webcomponents/tool/src/main/frontend/packages/sakai-element/src/global-styles.js b/webcomponents/tool/src/main/frontend/packages/sakai-element/src/global-styles.js index e6fce16c8667..247266e10ac3 100644 --- a/webcomponents/tool/src/main/frontend/packages/sakai-element/src/global-styles.js +++ b/webcomponents/tool/src/main/frontend/packages/sakai-element/src/global-styles.js @@ -1,13 +1,16 @@ +import { css, unsafeCSS } from "lit"; + let globalSheets = null; export function getGlobalStyleSheets() { if (globalSheets === null) { globalSheets = Array.from(document.styleSheets) .map(x => { - const sheet = new CSSStyleSheet(); - const css = Array.from(x.cssRules).map(rule => rule.cssText).join(" "); - sheet.replaceSync(css); - return sheet; + const cssText = Array.from(x.cssRules) + .filter(rule => rule.constructor.name !== "CSSImportRule") + .map(rule => rule.cssText) + .join(" "); + return css`${unsafeCSS(cssText)}`; }); }