Skip to content

[Quest]: Proper ShadowDOM support #20644

Open

Description

@NullVoxPopuli

Goal:

  • support rending in to a shadow-dom
  • be able to render in to a shadow-dom in a single render pass (the current way to get around limitations in ember/glimmer to render in to a shadow requires an extra render pass as well as an extra couple elements)

Potentially make this work:

const Shadowed = 
  <template shadowmoderoot="open">

  </template>;

export default
  <template>
    <Shadowed>
      
    </Shadowed>
  </template>;

or, we update our content-tag parser to allow:

export default
  <template>
    <template shadowmoderoot="open">
      shadow dom!
    </template>
  </template>;

// representation:
template(`
   <template shadowmoderoot="open">
      shadow dom!
   </template>
`)

Currently, <template shadowrootmode="open"> is not allowed in template-tag:

GlimmerVM doesn't render directly in to a shadow:

Related

Regressions?

Activity

  1. lifeart commented on May 27, 2025

    @lifeart
    Contributor

    Since updating parser is hard, we may try to workaround it on framework level.

    I think we could start with a plugin to compile template-like notation to internal representation like:

    {{#let (element "foo") as |foo|}}
       {{#in-element (shadow-proxy foo)}}
        content
       {{/if}}
    {{/let}}

    where shadow-proxy returns node.attachShadow({ mode: "open" });

    "public" api may looks like:

    <div>
      <html:template shadowmoderoot="open">
         My Shadow DOM inside DIV.
      </html:template>
    </div>
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions