preactjs / preact-custom-element

Wrap your component up as a custom element
MIT License
355 stars 52 forks source link

Add support for {mode: 'closed'} #74

Closed stevenle closed 1 year ago

stevenle commented 2 years ago

The current implementation of register(..., {shadow: true}), always attaches the shadow DOM in {mode: 'open'}. This is a request to add support for {mode: 'closed'} as well.

Relevant docs: https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM#basic_usage

Screen Shot 2022-09-09 at 3 14 20 AM

I'm happy to send a PR to support the above. The way I see it there are two options:

1) In addition to the option{shadow: true}, add support for {shadow: 'open'} and {shadow: 'closed'}.

2) Add a new option called mode, e.g.: {shadow: true, mode: 'closed'}.

Let me know which option is preferred and I'm happy to send over the PR, including updating the @types/ package.