Skip to content
Open
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7f91f78
Initial commit
KurtCattiSchmidt Sep 23, 2025
b8c96ae
Adding missing shadowrootadoptedstylesheets and other small fixes
KurtCattiSchmidt Sep 24, 2025
4487b30
Addressing Hoch's feedback
KurtCattiSchmidt Sep 24, 2025
fde2e28
Fixing order and removing duplicate shadowrootadoptedstylesheets
KurtCattiSchmidt Sep 24, 2025
141c474
Fixing shadowrootadoptedstylesheets to definition to not include clon…
KurtCattiSchmidt Sep 25, 2025
c174820
Wrapping algorithm per new requirements
KurtCattiSchmidt Sep 26, 2025
477caa7
Fixing formatting
KurtCattiSchmidt Sep 26, 2025
582566e
Merge branch 'main' into css-modules-firstpr
KurtCattiSchmidt Sep 26, 2025
ccac8fe
Fixing <li> conformance error
KurtCattiSchmidt Sep 26, 2025
746cdad
Simplifying stylesheet adopting steps
KurtCattiSchmidt Sep 29, 2025
ca450c7
Making stylesheet adopting steps append instead of set
KurtCattiSchmidt Sep 29, 2025
d8cae13
Fixing typo
KurtCattiSchmidt Sep 29, 2025
11fcb56
Addressing Dan's feedback
KurtCattiSchmidt Oct 6, 2025
9e2f7ee
Minor style fixes
KurtCattiSchmidt Oct 6, 2025
b2c6025
Addressing Dan's second round of feedback
KurtCattiSchmidt Oct 8, 2025
adf1484
Updating external URL references to draft URL's
KurtCattiSchmidt Oct 9, 2025
05edbed
Adding component percent-encode set per Anne's feedback
KurtCattiSchmidt Oct 9, 2025
6cee43f
Separating JSON string step into a JSON object + stringify
KurtCattiSchmidt Oct 9, 2025
6a95872
Updating wording on the 'type' attribute being obselete
KurtCattiSchmidt Oct 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 171 additions & 1 deletion source
Original file line number Diff line number Diff line change
Expand Up @@ -4109,6 +4109,14 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x-href="https://drafts.csswg.org/cssom-view/#set-up-browsing-context-features">set up browsing context features</dfn></li>
<li>The <dfn data-x="mouseevent-clientx" data-x-href="https://drafts.csswg.org/cssom-view/#dom-mouseevent-clientx">clientX</dfn> and <dfn data-x="mouseevent-clienty" data-x-href="https://drafts.csswg.org/cssom-view/#dom-mouseevent-clienty">clientY</dfn> extension attributes of the <span>MouseEvent</span> interface</li>
</ul>
<li>
<dfn data-x="concept-documentorshadowroot-extensions-mixin"
data-x-href="https://www.w3.org/TR/cssom-1/#extensions-to-the-document-or-shadow-root-interface">Extensions to the <code>DocumentOrShadowRoot</code> Interface Mixin</dfn>:
<ul class="brief">
<li><dfn data-x="concept-documentorshadowroot-extensions-mixin-stylesheets" data-x-href="https://www.w3.org/TR/cssom-1/#dom-documentorshadowroot-stylesheets">styleSheets</dfn></li>
<li><dfn data-x="adoptedstylesheets" data-x-href="https://www.w3.org/TR/cssom-1/#dom-documentorshadowroot-adoptedstylesheets">adoptedStyleSheets</dfn></li>
</ul>
</li>

<p>The following features and terms are defined in <cite>CSS Syntax</cite>:
<ref>CSSSYNTAX</ref></p>
Expand Down Expand Up @@ -17948,6 +17956,7 @@ people expect to have work and what is necessary.
<dd><span>Global attributes</span></dd>
<dd><code data-x="attr-style-media">media</code></dd>
<dd><code data-x="attr-style-blocking">blocking</code></dd>
<dd><code data-x="attr-style-specifier">specifier</code></dd>
<dd>Also, the <code data-x="attr-style-title">title</code> attribute <span data-x="attr-style-title">has special semantics</span> on this element.</dd>
<dt><span
data-x="concept-element-accessibility-considerations">Accessibility considerations</span>:</dt>
Expand All @@ -17962,6 +17971,7 @@ interface <dfn interface>HTMLStyleElement</dfn> : <span>HTMLElement</span> {
attribute boolean <span data-x="dom-style-disabled">disabled</span>;
[<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>] attribute DOMString <dfn attribute for="HTMLStyleElement" data-x="dom-style-media">media</dfn>;
[SameObject, PutForwards=<span data-x="dom-DOMTokenList-value">value</span>, <span data-x="xattr-Reflect">Reflect</span>] readonly attribute <span>DOMTokenList</span> <dfn attribute for="HTMLStyleElement" data-x="dom-style-blocking">blocking</dfn>;
[SameObject, PutForwards=value, Reflect] readonly attribute DOMString specifier;

// <a href="#HTMLStyleElement-partial">also has obsolete members</a>
};
Expand Down Expand Up @@ -18033,6 +18043,10 @@ console.log(style.disabled); // false</code></pre>
<p>The <dfn element-attr for="style"><code data-x="attr-style-blocking">blocking</code></dfn>
attribute is a <span>blocking attribute</span>.</p>

<p>The <dfn element-attr for="style"><code data-x="attr-style-specifier">specifier</code></dfn>
attribute defines an exportable <span
data-x="specifier-resolution-record-specifier">specifier</span>.</p>

<p id="title-on-style">The <dfn element-attr for="style"><code
data-x="attr-style-title">title</code></dfn> attribute on <code>style</code> elements defines
<span data-x="CSS style sheet set">CSS style sheet sets</span>. If the <code>style</code> element
Expand Down Expand Up @@ -18256,7 +18270,76 @@ console.log(style.disabled); // false</code></pre>

</div>

<p>The user agent must run the <span>create a declarative CSS module script</span> algorithm when
all of the following conditions are true:</p>

<ul>
<li><p>The element is popped off the <span>stack of open elements</span> of an <span>HTML
parser</span> or <span>XML parser</span>.</p></li>

<li><p>The element is not on the <span>stack of open elements</span> of an <span>HTML
parser</span> or <span>XML parser</span>, and it <span>becomes connected</span>.</p></li>
</ul>

<p>The <dfn export>create a declarative CSS module script</dfn> algorithm is as follows:</p>

<ol>
<li><p>Let <var>element</var> be the <code>style</code> element.</p></li>

<li><p>If <var>element</var> is not <span>connected</span>, then return.</p></li>
<!-- See:
https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2740
https://github.com/w3c/csswg-drafts/issues/3096 -->

<li><p>If <var>element</var>'s <code data-x="attr-style-type">type</code> attribute is present
and its value is not an <span>ASCII case-insensitive</span> match for
"<code data-x="">module</code>", then return.</p></li>

<li><p>If <var>element</var>'s <code data-x="attr-style-specifier">specifier</code> attribute
is not present or its value is an empty string, then return.</p></li>

<li><p>If the <span>Should element's inline behavior be blocked by Content Security
Policy?</span> algorithm returns "<code data-x="">Blocked</code>" when executed upon the
<code>style</code> element, "<code data-x="">style</code>", and the <code>style</code>
element's <span>child text content</span>, then return. <ref>CSP</ref></p></li>

<li><p>Let <var>styleDataURI</var> be the string "<code data-x="">data:text/css,</code>"
appended with the <span>child text content</span> of the <code>style</code>
element.</p></li>

<li>
<p>Create a JSON object with the following properties:</p>

<ol>
<li>A single key of "<code data-x="">imports</code>".</li>
<li>A single JSON value containing a <span>module specifier map</span> with a key consisting of
the value of <span data-x="attr-style-specifier">specifier attribute</span> and a value of a
<span data-x="UTF-8 percent-encode">UTF-8 percent-encoding</span> of <var>styleDataURI</var>.
</ol>
</li>
<li>Perform <span>parse an import map string</span> with <var>input</var> as the resulting JSON
string from the prior step and <var>baseURL</var> as the <span>document base URL</span>.</li>
</ol>

<div class="example">

<p>For example, a <code>style</code> element defined as follows:</p>

<pre><code class="html">
&lt;style type="module" specifier="foo">body { background: navy; color: yellow; }&lt;/style>
</code></pre>

<p>Is equivalent to the following <span>import map</span> definition:</p>

<pre><code class="html" data-x="">
&lt;script type="importmap">
{
"imports": {
"foo": "data%3Atext%2Fcss%2Cbody%20%7B%20background%3A%20navy%3B%20color%3A%20yellow%3B%20%7D"
}
}
&lt;/script></code></pre>
</div>

<div w-nodev>

Expand Down Expand Up @@ -65540,11 +65623,13 @@ not-slash = %x0000-002E / %x0030-10FFFF
<dd><span data-x="concept-content-nothing">Nothing</span> (for clarification, <a href="#template-example">see example</a>).</dd>
<dt><span data-x="concept-element-attributes">Content attributes</span>:</dt>
<dd><span>Global attributes</span></dd>
<dd><code data-x="attr-template-shadowrootadoptedstylesheets">shadowrootadoptedstylesheets</code></dd>
<dd><code data-x="attr-template-shadowrootmode">shadowrootmode</code></dd>
<dd><code data-x="attr-template-shadowrootdelegatesfocus">shadowrootdelegatesfocus</code></dd>
<dd><code data-x="attr-template-shadowrootclonable">shadowrootclonable</code></dd>
<dd><code data-x="attr-template-shadowrootserializable">shadowrootserializable</code></dd>
<dd><code data-x="attr-template-shadowrootcustomelementregistry">shadowrootcustomelementregistry</code></dd>
<dd><code data-x="attr-template-shadowrootadoptedstylesheets">shadowrootadoptedstylesheets</code></dd>
<dt><span
data-x="concept-element-accessibility-considerations">Accessibility considerations</span>:</dt>
<dd><a href="https://w3c.github.io/html-aria/#el-template">For authors</a>.</dd>
Expand All @@ -65556,6 +65641,7 @@ interface <dfn interface>HTMLTemplateElement</dfn> : <span>HTMLElement</span> {
[<span>HTMLConstructor</span>] constructor();

readonly attribute <span>DocumentFragment</span> <span data-x="dom-template-content">content</span>;
[<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>] attribute DOMString <dfn attribute for="HTMLTemplateElement" data-x="dom-template-shadowrootadoptedstylesheets">shadowRootAdoptedStyleSheets</dfn>;
[<span>CEReactions</span>] attribute DOMString <span data-x="dom-template-shadowrootmode">shadowRootMode</span>;
[<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>] attribute boolean <dfn attribute for="HTMLTemplateElement" data-x="dom-template-shadowrootdelegatesfocus">shadowRootDelegatesFocus</dfn>;
[<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>] attribute boolean <dfn attribute for="HTMLTemplateElement" data-x="dom-template-shadowrootclonable">shadowRootClonable</dfn>;
Expand Down Expand Up @@ -65613,6 +65699,11 @@ interface <dfn interface>HTMLTemplateElement</dfn> : <span>HTMLElement</span> {
data-x="attr-template-shadowrootcustomelementregistry">shadowrootcustomelementregistry</code></dfn>
content attribute is a <span>boolean attribute</span>.</p>

<p>The <dfn element-attr for="template"><code
data-x="attr-template-shadowrootadoptedstylesheets">shadowrootadoptedstylesheets</code></dfn> content
contributes to the <span data-x="concept-DocumentFragment-host">host's</span>
<span>adoptedStyleSheets</span>.</p>

<p>The <span>template contents</span> of a <code>template</code> element <a
href="#template-syntax">are not children of the element itself</a>.</p>

Expand Down Expand Up @@ -65823,7 +65914,73 @@ interface <dfn interface>HTMLTemplateElement</dfn> : <span>HTMLElement</span> {

</div>

<hr>

<p>The <dfn>stylesheet adopting steps</dfn> for <code>template</code> elements are:</p>

<ol>
<li><p>If the value of
<span data-x="attr-template-shadowrootadoptedstylesheets">shadowrootadoptedstylesheets</span> is
empty, then return.</p></li>
<li><p>Let <var>adoptedStyleSheets</var> be an empty array.</p></li>

<li><p>For each <span>unordered set of unique space-separated tokens</span> <var>specifier</var> in
<span data-x="attr-template-shadowrootadoptedstylesheets">shadowrootadoptedstylesheets</span>:</p>
<ol>
<li><p>Let <var>url</var> be the result of <span data-x="resolve a module specifier">resolving
a module specifier</span> given <var>moduleScript</var> and <var>specifier</var>.</p> If
any errors occur, continue.</li>
<li><p>Let <var>fetchClient</var> be the <span>current settings object</span>.</p></li>
<li><p>Let <var>destination</var> be the empty string.</li>
<li><p>Let <var>options</var> be the <span>default script fetch options</span>.</li>
<li><p>Let <var>settingsObject</var> be the <span>current settings object</span>.</li>
<li><p>Let <var>referrer</var> be "<code data-x="">client</code>".</li>
<li><p>Let <var>moduleRequest</var> be a <span>ModuleRequest Record</span> with
<code data-x="">specifier</code> set to <var>specifier</var></p></li>
<li>Perform <span>fetch a single module script</span> providing <var>url</var>,
<var>fetchClient</var>,<var>destination</var>,<var>options</var>,
<var>settingsObject</var>,<var>referrer</var>, and <var>moduleRequest</var> from the prior
steps.</li>
<li>If the prior step immediately succeeds, extract the <code>CSSStyleSheet</code> from the
response's <span data-x="concept-script-record">record</span> and append it to
<var>adoptedStyleSheets</var>. If any failure occurs, continue.</li>
</ol>
</li>
<li>Set <span>adoptedStyleSheets</span> on the <span data-x="concept-DocumentFragment-host">host</span>
to <var>adoptedStyleSheets</var>.</li>
</ol>

<div class="example">

<p>This example demonstrates two equivalent methods to import CSS module scripts, the
first using the JavaScript <code data-x="">import</code> method and the second using the
<span data-x="attr-template-shadowrootadoptedstylesheets">shadowrootadoptedstylesheets</span>
attribute.</p>

<pre><code class="html">
&lt;script type="importmap">
{
"imports": {
"foo": "data:text/css,div {color:blue}"
}
}
&lt;/script>
&lt;div id="host">
&lt;template shadowrootmode="open">
&lt;script type="module">
import styles from "foo" with { type: "css"};
document.getElementById("host").shadowRoot.adoptedStyleSheets = [styles];
&lt;/script>
&lt;div>test&lt;/div>
&lt;/template>
&lt;/div>
&lt;div id="host_shadowrootadoptedstylesheets_attribute">
&lt;template shadowrootmode="open" shadowrootadoptedstylesheets="foo">
&lt;div>test&lt;/div>
&lt;/template>
&lt;/div></code></pre>

</div>

<div w-nodev>

Expand Down Expand Up @@ -146502,7 +146659,8 @@ interface <dfn interface>External</dfn> {
<td>text*</td>
<td><span data-x="global attributes">globals</span>;
<code data-x="attr-style-media">media</code>;
<code data-x="attr-style-blocking">blocking</code></td>
<code data-x="attr-style-blocking">blocking</code>
<code data-x="attr-style-specifier">specifier</code></td>
<td><code>HTMLStyleElement</code></td>
</tr>

Expand Down Expand Up @@ -146608,6 +146766,7 @@ interface <dfn interface>External</dfn> {
<code>colgroup</code>*</td>
<td>empty</td>
<td><span data-x="global attributes">globals</span>;
<code data-x="attr-template-shadowrootadoptedstylesheets">shadowrootadoptedstylesheets</code>;
<code data-x="attr-template-shadowrootmode">shadowrootmode</code>;
<code data-x="attr-template-shadowrootdelegatesfocus">shadowrootdelegatesfocus</code>;
<code data-x="attr-template-shadowrootclonable">shadowrootclonable</code>;
Expand Down Expand Up @@ -148125,6 +148284,11 @@ interface <dfn interface>External</dfn> {
<td> <code data-x="attr-option-selected">option</code>
<td> Whether the option is selected by default
<td> <span>Boolean attribute</span>
<tr>
<th> <code data-x="attr-template-shadowrootadoptedstylesheets">shadowrootadoptedstylesheets</code>
<td> <code data-x="attr-template-shadowrootclonable">template</code>
<td> Sets <span>adoptedStyleSheets</span> on a declarative shadow root
<td> <a href="#attribute-text">Text</a>
<tr>
<th> <code data-x="">shadowrootclonable</code>
<td> <code data-x="attr-template-shadowrootclonable">template</code>
Expand Down Expand Up @@ -148194,6 +148358,11 @@ interface <dfn interface>External</dfn> {
<td> "<code data-x="attr-spellcheck-true">true</code>";
"<code data-x="attr-spellcheck-false">false</code>";
the empty string
<tr>
<th> <code data-x="">specifier</code>
<td> <code data-x="attr-style-blocking">style</code>
<td> A <var>specifier</var> value used in a <span>module specifier map</span>
<td> <a href="#attribute-text">Text</a>
<tr>
<th> <code data-x="">src</code>
<td> <code data-x="attr-media-src">audio</code>;
Expand Down Expand Up @@ -151209,6 +151378,7 @@ INSERT INTERFACES HERE
Kristof Zelechovski,
Krzysztof Maczy&#x0144;ski,
&#x9ed2;&#x6fa4;&#x525b;&#x5fd7; (Kurosawa Takeshi),
Kurt Catti-Schmidt,
Kyle Barnhart,
Kyle Hofmann<!-- Ozob -->,
Kyle Huey,
Expand Down
Loading