diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2024-06-16 10:10:57 +0100 |
---|---|---|
committer | Hayleigh Thompson <me@hayleigh.dev> | 2024-06-16 10:10:57 +0100 |
commit | a924297b13039e752c6bbd12d9a8ee429a2d4e63 (patch) | |
tree | 7d529cb210b6e38948a7ba69fc7a8058a35522a7 /src/client-component.ffi.mjs | |
parent | 57fb60de92c81e4e344f8109d51ea2d1a4996bd0 (diff) | |
download | lustre-a924297b13039e752c6bbd12d9a8ee429a2d4e63.tar.gz lustre-a924297b13039e752c6bbd12d9a8ee429a2d4e63.zip |
:recycle: Inherit component styles by cloning link/style tags.
Diffstat (limited to 'src/client-component.ffi.mjs')
-rw-r--r-- | src/client-component.ffi.mjs | 13 |
1 files changed, 7 insertions, 6 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, |