MicrosoftEdge / MicrosoftEdge/MSEdgeExplainers
[Declarative Shadow DOM Style Sharing] consider compatibility between declarative and imperative use
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 1.4k
- Forks
- 286
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 8
Description
It's common for users to create Shadow DOM imperatively in custom elements. Libraries can then server side render SSR the result into declarative Shadow DOM that later upgrades to a loaded custom element. The solution here should integrate well with both approaches.
Using the module graph for this is a good start, so I want to confirm that the following would work:
<script type="css-module" indentifier="/styles.css">
:host { display: block; background: green; }
</script>
<div>
<template shadowrootmode="open" adoptedstylesheets="./styles.css">Hi</template>
</div>
<x-foo></x-foo>
<script type="module">
import sheet from './styles.css' with { type: 'css' };
import otherSheet from './load-styles.css' with { type: 'css' };
customElements.define('x-foo', class extends HTMLElement {
constructor() {
super();
this.attachShadow({mode: 'open'}).innerHTML = 'hi';
this.shadowRoot.adoptedStyleSheets.push(sheet, otherSheet);
}
});
</script>
<div>
<template shadowrootmode="open" adoptedstylesheets="./load-styles.css">Hi</template>
</div>
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start by reviewing the issue's declarative and imperative Shadow DOM example, including the module graph and CSS module imports. No files or tests are named; done would require defining and confirming compatibility requirements for both server-rendered declarative shadow roots and custom elements that attach shadow roots imperatively.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, html, javascript
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100