Skip to content

Allow passing custom options to shadow DOM constructor #17080

@Bladesheng

Description

@Bladesheng

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions