You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<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>
<p>Summary or proposal based on current status; paragraph(s) and code.</p>
602
+
<preclass="javascript">
603
+
import styleSheet from "./styles.css" assert { type: "css" };
604
+
605
+
document.adoptedStyleSheets = [ styleSheet ];
606
+
</pre>
606
607
</section>
607
608
<section>
608
609
<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 `<style>` or `<link>` 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: <ahref="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>
610
618
</section>
611
619
<section>
612
620
<h3>Concerns</h3>
613
621
<ul>
614
-
<li>---</li>
622
+
<li>Safari has a security concern regarding <ahref="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 <ahref="https://github.com/w3ctag/design-reviews/issues/405#issuecomment-561304217">how to handle <code>@import</code> statements in CSS Modules.</a></li>
615
624
</ul>
616
625
</section>
617
626
<section>
@@ -623,7 +632,7 @@ <h3>Dissenting Opinion</h3>
623
632
<section>
624
633
<h3>Related Specs</h3>
625
634
<ul>
626
-
<li>---</li>
635
+
<li>This has a pre-requisite on <ahref="#constructable-stylesheets-adoptedstylesheets">Constructable Stylesheets</a> landing.</li>
0 commit comments