ProjectEvergreen / ProjectEvergreen/wcc
optimize how initial HTML is set on initial render for JSX usage (Shadow DOM detection)
Open
@KaiPrince is already working on this.
Since Mar 19, 2026.
enhancement
good first issue
JSX
- Dominant language
- JavaScript
- Stars
- 126
- Forks
- 17
- PR merge metrics
- No merged PRs in 30d
Description
Summary
Currently as part of initializing a component (either Light or Shadow DOM) from render function when using JSX, we use innerHTML in a couple scenarios
- Light DOM uses
innerHTML - Shadow DOM, if there is a root but no HTML (like say injecting dynamic content at run time, a la htmx)
const renderHandler = hasShadowRoot
? `
const template = document.createElement('template');
template.innerHTML = \`${serializedHtml}\`;
if(!${elementRoot}) {
this.attachShadow({ mode: 'open' });
this.shadowRoot.appendChild(template.content.cloneNode(true));
} else {
this.shadowRoot.innerHTML = template.innerHTML;
}
`
: `${elementRoot}.innerHTML = \`${serializedHtml}\`;`;
Details
It would be nice in either of these cases if we could just "push" the template right into the node, instead of using innerHTML which has a couple downsides
- In some cases it just wont work - #130
- even if it did, it invokes the HTML parser, which is an overhead
- potential security concern around XSS
So, instead would be nice to see if we could leverage actual DOM APIs , like say replaceWith, just like we are able to leverage appendNode.
const renderHandler = hasShadowRoot
? `
const template = document.createElement('template');
template.innerHTML = \`${serializedHtml}\`;
if(!${elementRoot}) {
this.attachShadow({ mode: 'open' });
this.shadowRoot.appendChild(template.content.cloneNode(true));
} else {
this.shadowRoot.replaceNode(template);
}
`
: `${elementRoot}.innerHTML = \`${serializedHtml}\`;`;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.