-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Declarative CSS Modules #11687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Declarative CSS Modules #11687
Changes from 23 commits
7f91f78
b8c96ae
4487b30
fde2e28
141c474
c174820
477caa7
582566e
ccac8fe
746cdad
ca450c7
d8cae13
11fcb56
9e2f7ee
b2c6025
adf1484
05edbed
6cee43f
6a95872
188162a
e9fb25a
3992d68
9bf97b2
0436d16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3123,6 +3123,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute | |
| <li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-isdatadescriptor">IsDataDescriptor</dfn> abstract operation</li> | ||
| <li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-isdetachedbuffer">IsDetachedBuffer</dfn> abstract operation</li> | ||
| <li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-issharedarraybuffer">IsSharedArrayBuffer</dfn> abstract operation</li> | ||
| <li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-json.stringify">JSON.stringify</dfn> abstract operation</li> | ||
| <li>The <dfn data-x="js-NewObjectEnvironment" data-x-href="https://tc39.es/ecma262/#sec-newobjectenvironment">NewObjectEnvironment</dfn> abstract operation</li> | ||
| <li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-normalcompletion">NormalCompletion</dfn> abstract operation</li> | ||
| <!-- the next set of Ordinary* abstract operations are in order of appearance --> | ||
|
|
@@ -18513,6 +18514,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> | ||
|
|
@@ -18527,6 +18529,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> | ||
| }; | ||
|
|
@@ -18602,6 +18605,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 | ||
|
|
@@ -18831,7 +18838,86 @@ 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> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this just a subset of the next condition?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The next condition is inverted - "The element is not on the..." This language already exists in https://html.spec.whatwg.org/#the-style-element:update-a-style-block |
||
|
|
||
| <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> | ||
|
|
||
| <div algorithm> | ||
| <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 not present | ||
| or its value is not an <span>ASCII case-insensitive</span> match for | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this is also the point where we'd also check a new equivalent of the already started flag to ensure a given
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I'll have to think about this a little more. I will likely bring this up soon with the WHATWG.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't seem like this got addressed one way or another?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll bring this part up at the next meeting |
||
| "<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 | ||
|
KurtCattiSchmidt marked this conversation as resolved.
Outdated
|
||
| Policy?</span> algorithm returns "<code data-x="">Blocked</code>" when executed upon the | ||
|
KurtCattiSchmidt marked this conversation as resolved.
Outdated
|
||
| <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>styleBlob</var> be the result of creating a <span>Blob</span> object representing | ||
| a file containing the <code>style</code> element's <span>child text content</span> with a | ||
| <code data-x="dom-Blob-type">type</code> of "<code>text/css</code>".</p></li> | ||
|
|
||
| <li><p>Let <var>styleBlobURL</var> be the <span data-x="concept-url-blob-entry">blob URL entry</span> | ||
| associated with <var>styleBlob</var>.</p></li> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not how this works. A
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is super helpful, thank you! I updated it to account for this, but it could use another look. |
||
|
|
||
| <li><p>Create a JSON object <var>jsonObject</var> with a single key of "<code data-x="">imports</code>" | ||
| whose value is a single JSON object containing a <span>module specifier map</span> with a key consisting | ||
|
KurtCattiSchmidt marked this conversation as resolved.
Outdated
|
||
| of the value of the <span data-x="attr-style-specifier">specifier attribute</span> and a value of | ||
| <var>styleBlobURL</var>.</p></li> | ||
|
|
||
| <li><p>Let <var>jsonString</var> be the result of calling <span>JSON.stringify</span> on | ||
| <var>jsonObject</var>.</p></li> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong. We should be using Infra primitives for JSON.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But "create an import map parse result" takes a string, should we change that to allow raw JSON? |
||
|
|
||
| <li><p>Let <var>importMapParseResult</var> be the result of <span>create an import map parse result</span> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. For now I added a step to look at the importMapParseResult's error to rethrow and to continue if that happens. In practice, we probably want to log something in the console, but this might be enough for the spec. |
||
| with <var>input</var> as <var>jsonString</var> and <var>baseURL</var> as the <span>document base URL</span>.</p></li> | ||
|
KurtCattiSchmidt marked this conversation as resolved.
Outdated
|
||
|
|
||
| <li><p>If <var>importMapParseResult</var>'s <span data-x="impr-error-to-rethrow">error to rethrow</span> is | ||
| not null, then return.</p></li> | ||
|
KurtCattiSchmidt marked this conversation as resolved.
Outdated
KurtCattiSchmidt marked this conversation as resolved.
Outdated
|
||
|
|
||
| <li><p><span>Register an import map</span> using <var>element</var>'s <span>relevant global object</span> | ||
| and <var>importMapParseResult</var>.</p></li> | ||
|
KurtCattiSchmidt marked this conversation as resolved.
Outdated
|
||
| </ol> | ||
|
KurtCattiSchmidt marked this conversation as resolved.
Outdated
|
||
| </div> | ||
|
|
||
| <div class="example"> | ||
|
|
||
| <p>For example, a <code>style</code> element defined as follows:</p> | ||
|
|
||
| <pre><code class="html"> | ||
| <style type="module" specifier="foo">body { background: navy; color: yellow; }</style> | ||
| </code></pre> | ||
|
|
||
| <p>Is equivalent to the following dynamically created <span>import map</span> definition:</p> | ||
|
|
||
| <pre><code class="html" data-x=""> | ||
| <script> | ||
| const blob_url = URL.createObjectURL(new Blob(["body { background: navy; color: yellow; }"], {type: "text/css"})); | ||
| const import_map = document.createElement("script"); | ||
| import_map.setAttribute("type", "importmap"); | ||
| const json_string = "{ \"imports\": { \"foo\": \"" + blob_url + "\" }}"; | ||
| import_map.innerText = json_string; | ||
| document.body.appendChild(import_map); | ||
| </script></code></pre> | ||
| </div> | ||
|
|
||
| <div w-nodev> | ||
|
|
||
|
|
@@ -68108,8 +68194,6 @@ interface <dfn interface>HTMLTemplateElement</dfn> : <span>HTMLElement</span> { | |
|
|
||
| </div> | ||
|
|
||
|
|
||
|
|
||
| <div w-nodev> | ||
|
|
||
| <h5 id="template-XSLT-XPath">Interaction of <code>template</code> elements with XSLT and XPath</h5> | ||
|
|
@@ -140229,6 +140313,7 @@ document.body.appendChild(text); | |
| data-x="attr-template-shadowrootcustomelementregistry">shadowrootcustomelementregistry</code> | ||
| attribute, then set <var>shadow</var>'s <span>keep custom element registry null</span> to | ||
| true.</p></li> | ||
|
|
||
| </ol> | ||
| </li> | ||
| </ol> | ||
|
|
@@ -148489,9 +148574,10 @@ if (s = prompt('What is your name?')) { | |
| attribute on <code>script</code> elements that is the empty string or a <span>JavaScript MIME type | ||
| essence match</span>. Instead, they should omit the attribute, which has the same effect.</p> | ||
|
|
||
| <p>Authors should not specify a <code data-x="attr-style-type">type</code> attribute on a | ||
| <code>style</code> element. If the attribute is present, its value must be an <span>ASCII | ||
| case-insensitive</span> match for "<code>text/css</code>".</p> | ||
| <p>Authors should not specify a value for the <code data-x="attr-style-type">type</code> | ||
| attribute on <code>style</code> elements, if that value is an <span>ASCII case-insensitive</span> | ||
| match for "<code>text/css</code>". Instead, they should omit the attribute, which has the same | ||
| effect.</p> | ||
|
KurtCattiSchmidt marked this conversation as resolved.
Outdated
|
||
|
|
||
| <p>Authors should not specify the <code data-x="attr-a-name">name</code> attribute on | ||
| <code>a</code> elements. If the attribute is present, its value must not be the empty string and | ||
|
|
@@ -148799,7 +148885,7 @@ if (s = prompt('What is your name?')) { | |
| <dd><p>Use DOM events mechanisms to register event listeners. <ref>DOM</ref></p></dd> | ||
|
|
||
| <dt><dfn element-attr for="style"><code data-x="attr-style-type">type</code></dfn> on <code>style</code> elements (except as noted in the previous section)</dt> | ||
|
KurtCattiSchmidt marked this conversation as resolved.
Outdated
|
||
| <dd><p>Omit the attribute for CSS; for <span data-x="data block">data blocks</span>, use | ||
| <dd><p>Omit the attribute for CSS (unless used to <span>create a declarative CSS module script</span>); for <span data-x="data block">data blocks</span>, use | ||
| <code>script</code> as the container instead of <code>style</code>.</p></dd> | ||
|
|
||
| <dt><dfn element-attr for="table"><code data-x="attr-table-datapagesize">datapagesize</code></dfn> on <code>table</code> elements</dt> | ||
|
|
@@ -151699,7 +151785,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> | ||
|
|
||
|
|
@@ -153391,6 +153478,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-specifier">style</code> | ||
| <td> A <span data-x="specifier-resolution-record-specifier">specifier</span> 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>; | ||
|
|
@@ -156406,6 +156498,7 @@ INSERT INTERFACES HERE | |
| Kristof Zelechovski, | ||
| Krzysztof Maczyński, | ||
| 黒澤剛志 (Kurosawa Takeshi), | ||
| Kurt Catti-Schmidt, | ||
| Kyle Barnhart, | ||
| Kyle Hofmann<!-- Ozob -->, | ||
| Kyle Huey, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on this? Are you saying that
specifiershould be parser-only?