Skip to content

Commit f86517c

Browse files
first draft of CSS modules (#58)
1 parent 8c4c6e6 commit f86517c

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

reports/2022.html

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -579,39 +579,48 @@ <h3>Links</h3>
579579
<dt>Previous WCCG Report(s)</dt>
580580
<dd><a href="https://w3c.github.io/webcomponents-cg/index.html#css-module-scripts">2021</a></dd>
581581
<dt>GitHub issues:</dt>
582-
<dd>---</dd>
582+
<dd><a href="https://github.com/WICG/webcomponents/issues/759">WICG/webcomponents#759</a></dd>
583583
<dt>Browser positions:</dt>
584-
<dd>---</dd>
584+
<dd><a href="https://web.dev/css-module-scripts/">Chrome</a></dd>
585+
<dd><a href="https://mozilla.github.io/standards-positions/#import-attributes">Firefox</a></dd>
585586
</dl>
586587
</section>
587588
<section>
588589
<h3>Description</h3>
589-
<p>---</p>
590-
</section>
591-
<section>
592-
<h3>Links</h3>
593-
<ul>
594-
<li>---</li>
595-
</ul>
590+
<p>CSS Module Scripts allow JavaScript modules to import style sheets. They can then be applied to a document or shadow root using adoptedStyleSheets in the same way as constructible style sheets.</p>
596591
</section>
597592
<section>
598593
<h3>Status</h3>
599594
<ul>
600-
<li>---</li>
595+
<li><a href="https://chromestatus.com/feature/5948572598009856">Chrome (shipped)</a></li>
596+
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1720570">Firefox</a></li>
597+
<li><a href="https://bugs.webkit.org/show_bug.cgi?id=227967">Safari</a></li>
601598
</ul>
602599
</section>
603600
<section>
604601
<h3>Initial API Summary/Quick API Proposal</h3>
605-
<p>Summary or proposal based on current status; paragraph(s) and code.</p>
602+
<pre class="javascript">
603+
import styleSheet from "./styles.css" assert { type: "css" };
604+
605+
document.adoptedStyleSheets = [ styleSheet ];
606+
</pre>
606607
</section>
607608
<section>
608609
<h3>Key Scenarios</h3>
609-
<p>---</p>
610+
<h3>Motivation</h3>
611+
<ul>
612+
<li>CSS modules will allow styles to be loaded in component definitions without adding `&lt;style&gt;` or `&lt;link&gt;` elements that need to be created in each element instance.</li>
613+
<li>Authors today often use inlined CSS strings in JS modules, but many of them want to move the CSS into separate .css files.</li>
614+
<li>Without CSS-in-JS it's difficult to ensure that CSS is loaded before the component is defined and rendered. CSS module scripts provide the same ordering guarantee.</li>
615+
<li>Component authors may need to import a resource that is only available as an external .css file, and don't have control over the resource to wrap it in a JS module.</li>
616+
</ul>
617+
<p>For further motivational details, see this explainer document: <a href="https://github.com/WICG/webcomponents/blob/gh-pages/proposals/css-modules-v1-explainer.md#why-are-css-modules-needed">webcomponents/css-modules-v1-explainer.md at gh-pages · WICG/webcomponents</a>.</p>
610618
</section>
611619
<section>
612620
<h3>Concerns</h3>
613621
<ul>
614-
<li>---</li>
622+
<li>Safari has a security concern regarding <a href="https://github.com/w3ctag/design-reviews/issues/405#issuecomment-535478821">the result of a loaded module.</a></li>
623+
<li>Safari wants to better understand <a href="https://github.com/w3ctag/design-reviews/issues/405#issuecomment-561304217">how to handle <code>@import</code> statements in CSS Modules.</a></li>
615624
</ul>
616625
</section>
617626
<section>
@@ -623,7 +632,7 @@ <h3>Dissenting Opinion</h3>
623632
<section>
624633
<h3>Related Specs</h3>
625634
<ul>
626-
<li>---</li>
635+
<li>This has a pre-requisite on <a href="#constructable-stylesheets-adoptedstylesheets">Constructable Stylesheets</a> landing.</li>
627636
</ul>
628637
</section>
629638
<section>

0 commit comments

Comments
 (0)