Skip to content

Styles not being properly imported when using shadow DOM #6

Open
@patricknelson

Description

@patricknelson

This is currently low priority for me personally (since I do not use the shadow DOM), but welcome a PR to fix this if anyone is interested and has the time. The only reason I think it's still worthwhile to consider supporting shadow DOM is because it brings some important svelte-retag specific features to existing capability in Svelte, i.e.

  1. Vite HMR compatibility
  2. Composability (i.e. easily use normally internally within Svelte + the ability to define custom elements as needed)

🤔 FWIW, it appears that this affects the original fork svelte-tag as well. Anyway, see below.


Describe the bug

Styles from the component itself work fine in light DOM, but when using shadow DOM (at least in development mode) the CSS styles from the component do not appear to be injected at all into the component.

Reproduction

JavaScript

import svelteRetag from 'svelte-retag';
import HelloWorld from './HelloWorld.svelte';

svelteRetag({ component: HelloWorld, tagname: 'hello-world', shadow: true });

HTML

<hello-world></hello-world>

Svelte component

<div>Hello world</div>


<style>
	div {
		border: 1px dotted red;
	}
</style>

Logs

No response

System Info

System:
    OS: Linux 5.15 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (16) x64 Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz
    Memory: 2.26 GB / 5.79 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.14.2/bin/yarn
    npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
  Browsers:
    Chrome: 111.0.5563.146
  npmPackages:
    svelte: ^3.57.0 => 3.58.0
    svelte-retag: ^0.0.3 => 0.0.7

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions