sveltejs/svelte

Allow passing custom options to shadow DOM constructor

Opened this issue · 1 comments

Describe the problem

Currently, the only thing you can pass to shadow DOM contructor is either mode: "open" or nothing at all.
https://svelte.dev/docs/svelte/custom-elements#Component-options

This means that you can't create shadow DOM with closed shadow root or change any other options of attachShadow().

Describe the proposed solution

Instead of passing only "none" to the shadow custom element option, allow passing the whole options object, which would be then passed to attachShadow().

This would allow changing shadow root mode to closed and would also allow you to customize all the other options.

This would probably be considered a breaking change for everyone already using shadow: "none", so you should be able to still pass either:

  • shadow: "none" or shadow: "open" - to maintain backwards compatibility
  • something like shadow: { mode: 'closed', clonable: false } (or any other options)

Importance

nice to have

ls-bit commented

this would be great, it would enable us to pass a scoped custom element registry