-
Notifications
You must be signed in to change notification settings - Fork 264
Description
I think that the title and framing of this proposal are causing a lot of confusion among reviewers. The current background and problem statement make it sound like this proposal is starting from the position of finding a way to share styles among shadow roots, and reviewers seem to take that as a cue to look at the entire problem and solution space of sharing styles, causing them to broaden the scope to other issues or try to invent new ways of sharing styles.
As I mentioned in my original proposal in WICG/webcomponents#939, the core problem is:
Declarative shadow roots and constructible stylesheets need to be made to work together so that stylesheets added to shadow roots can be round-tripped through HTML serialization and deserialization.
I would suggest these main points for background:
- The most common way, by far, of styling web components today is with
adoptedStyleSheetswhich allow sharing styles across multiple shadow roots adoptedStyleSheetsare not representable in HTML
This leads to workarounds for SSR:
- Convert
adoptedStyleSheetsto<style>tags during SSR. This causes duplication and breaks theadoptedStyleSheetssemantics - Convert
adoptedStyleSheetsto some non-style representation (ie<script>) and use JavaScript to adopt the styles. This doesn't work with JS disabled and may cause FOUC.
Style duplication, FOUC, and requiring JS are just problems with the available workarounds though. The core problem at hand is still that adoptedStyleSheets are not serializable nor compatible with declarative shadow DOM.
When the proposal leads with duplication as the problem, it sounds like good solutions may include novel ways of sharing styles. But a novel style sharing solution that doesn't support serializing adoptedStyleSheets would still leave us in a place where we need this proposal in order to support adoptedStyleSheets. In other words, we already have style sharing, we just need to make representable in HTML.
So I would rename the proposal to something like "Declarative adoptedStyleSheets" and focus the background and problem statement on the lack of serializability.