Skip to content

Commit 015934f

Browse files
Merge pull request #50 from w3c/report-2022-constructable-stylesheets
Constructable Stylesheets
2 parents 690c40c + 89dd61b commit 015934f

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

reports/2022.html

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -481,34 +481,56 @@ <h3>Links</h3>
481481
<dt>Previous WCCG Report(s)</dt>
482482
<dd><a href="https://w3c.github.io/webcomponents-cg/index.html#constructable-stylesheets-adoptedstylesheets">2021</a></dd>
483483
<dt>GitHub issues:</dt>
484-
<dd>---</dd>
484+
<dd><a href="https://github.com/WICG/webcomponents/issues/468">WICG/webcomponents#468</a></dd>
485485
<dt>Browser positions:</dt>
486-
<dd>---</dd>
486+
<dd><a href="https://chromestatus.com/feature/5394843094220800" target="_blank">Chrome (Shipped)</a></dd>
487+
<dd><a href="https://github.com/mozilla/standards-positions/issues/103" target="_blank">Mozilla (Shipped)</a></dd>
488+
<dd><a href="https://github.com/WebKit/standards-positions/issues/42" target="_blank">Safari</a></dd>
487489
</dl>
488490
</section>
489491
<section>
490492
<h3>Description</h3>
491-
<p>---</p>
493+
<p><a href="https://wicg.github.io/construct-stylesheets/" target="_blank">Constructable Stylesheets</a> and adoptedStyleSheets enable adding styles directly to DOM trees, e.g. `document` and shadow roots, without creating new DOM elements. Because a single stylesheet object can be adopted by multiple scopes, it also allows sharing of styles that can be centrally modified.</p>
492494
</section>
493495
<section>
494496
<h3>Status</h3>
495497
<ul>
496-
<li>---</li>
498+
<li>Partial consensus; shipped in both <a href="https://web.dev/constructable-stylesheets/" target="_blank">Chrome</a> and <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1520690" target="_blank">Firefox</a></li>
497499
</ul>
498500
</section>
499501
<section>
500502
<h3>Initial API Summary/Quick API Proposal</h3>
501-
<p>Summary or proposal based on current status; paragraph(s) and code.</p>
503+
<p>The following is <a href="https://web.dev/constructable-stylesheets/#using-constructed-stylesheets" target="_blank">an example</a> of what this would look like in practice.</p>
504+
<pre>
505+
const sheet = new CSSStyleSheet();
506+
sheet.replaceSync('a { color: red; }');
507+
508+
// Apply the stylesheet to a document:
509+
document.adoptedStyleSheets = [sheet];
510+
511+
// Apply the stylesheet to a Shadow Root:
512+
const node = document.createElement('div');
513+
const shadow = node.attachShadow({ mode: 'open' });
514+
shadow.adoptedStyleSheets = [sheet];
515+
</pre>
502516
</section>
503517
<section>
504518
<h3>Key Scenarios</h3>
505-
<p>---</p>
519+
<ul>
520+
<li>There is no effective way to share styles across components while allowing them to be centrally modified.</li>
521+
<li>Creating `&lt;style&gt;` elements for each style used in each shadow root has a measurable performance overhead.</li>
522+
<li>CSS Module Scripts, another critical feature, depends on constructible stylesheets.</li>
523+
</ul>
506524
</section>
507525
<section>
508526
<h3>Concerns</h3>
509-
<ul>
510-
<li>---</li>
511-
</ul>
527+
<p>From their standards position tracker, Safari has highlighted some of the following concerns:</p>
528+
<ul>
529+
<li>Issues related to <a href="https://github.com/WICG/construct-stylesheets/issues/45" target="_blank">race conditions</a> with adopting stylesheets and if the adoptedStyleSheets array should be directly mutable or not</li>
530+
<li>There is concern that it is <a href="https://github.com/whatwg/dom/pull/892#pullrequestreview-593774559" target="_blank">incompatible with Declarative Shadow DOM</a>.</li>
531+
<li>Outstanding questions around <a href="https://github.com/WICG/webcomponents/issues/870" target="_blank"><em>@import</em> statements in CSS Modules</a>.</li>
532+
</ul>
533+
</p>
512534
</section>
513535
<section>
514536
<h3>Dissenting Opinion</h3>
@@ -519,7 +541,8 @@ <h3>Dissenting Opinion</h3>
519541
<section>
520542
<h3>Related Specs</h3>
521543
<ul>
522-
<li>---</li>
544+
<li><a href="/#declarative-shadow-dom" target="_blank">Declarative Shadow DOM</a></li>
545+
<li><a href="/#css-module-scripts" target="_blank">CSS Module Scripts</a></li>
523546
</ul>
524547
</section>
525548
<section>

0 commit comments

Comments
 (0)