Subscribe on changes!

Access `shadowRoot` inside `defineCustomElement`

avatar
Jun 14th 2022

What problem does this feature solve?

For CSS in JS component, it needs to mount some styles in shadowRoot before it's actually rendered. Seems currently there's no way to access it.

What does the proposed API look like?

Not sure. Maybe useShadowRoot if it can access shadow root before element is actually mounted.

defineCustomElement({
  setup () {
    const shadowRoot = useShadowRoot()
    // ... dynamically generate styles
    shadowRoot.appendChild(styleElement) 
  }
})