diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client-component.ffi.mjs | 13 | ||||
-rw-r--r-- | src/server-component.mjs | 19 |
2 files changed, 16 insertions, 16 deletions
diff --git a/src/client-component.ffi.mjs b/src/client-component.ffi.mjs index ce8607b..e93764b 100644 --- a/src/client-component.ffi.mjs +++ b/src/client-component.ffi.mjs @@ -72,15 +72,16 @@ function makeComponent(init, update, view, on_attribute_change) { } connectedCallback() { - const sheet = new CSSStyleSheet(); - - for (const { cssRules } of document.styleSheets) { - for (const rule of cssRules) { - sheet.insertRule(rule.cssText); + for (const link of document.querySelectorAll("link")) { + if (link.rel === "stylesheet") { + this.#shadow.appendChild(link.cloneNode(true)); } } - this.#shadow.adoptedStyleSheets = [sheet]; + for (const style of document.querySelectorAll("style")) { + this.#shadow.appendChild(style.cloneNode(true)); + } + this.#application = new LustreClientApplication( init(), update, diff --git a/src/server-component.mjs b/src/server-component.mjs index 31cd364..d4cb4a9 100644 --- a/src/server-component.mjs +++ b/src/server-component.mjs @@ -49,19 +49,18 @@ export class LustreServerComponent extends HTMLElement { } connectedCallback() { - this.#root = document.createElement("div"); - this.#shadow.appendChild(this.#root); - - const sheet = new CSSStyleSheet(); - - for (const { cssRules } of document.styleSheets) { - for (const rule of cssRules) { - console.log(rule); - sheet.insertRule(rule.cssText); + for (const link of document.querySelectorAll("link")) { + if (link.rel === "stylesheet") { + this.#shadow.appendChild(link.cloneNode(true)); } } - this.#shadow.adoptedStyleSheets = [sheet]; + for (const style of document.querySelectorAll("style")) { + this.#shadow.appendChild(style.cloneNode(true)); + } + + this.#root = document.createElement("div"); + this.#shadow.appendChild(this.#root); } attributeChangedCallback(name, prev, next) { |