diff --git a/source b/source index 8419eda4468..b99bb2e5998 100644 --- a/source +++ b/source @@ -4107,6 +4107,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
CSSStyleSheetCSSStyleSheetDocumentOrShadowRoot Interface Mixin:
+ shadowrootclonableshadowrootserializableshadowrootcustomelementregistryshadowrootadoptedstylesheetsThe shadowrootadoptedstylesheets content
+ contributes to the host's
+ adoptedStyleSheets.
The template contents of a template element are not children of the element itself.
The stylesheet adopting steps for template elements are:
If the value of + shadowrootadoptedstylesheets is + empty, then return.
Let adoptedStyleSheets be an empty array.
For each ordered set of unique space-separated tokens specifier in + shadowrootadoptedstylesheets:
+Let url be the result of resolving + a module specifier with specifier.
If + any errors occur, then continue.Let settingsObject be the current settings object.
Let moduleType be "css".
Let moduleMap be settingsObject's module map.
Let moduleScript be + moduleMap[(url, moduleType)].
If moduleScript is null, fetch a single module script given
+ url, settingsObject, "style", the
+ default script fetch options, settingsObject, "client", true
Extract the CSSStyleSheet from moduleScript's
+ record and append it to
+ adoptedStyleSheets. If any error occurs, remove all instances of the associated
+ CSSStyleSheet from adoptedStyleSheetsand continue.
Extend host's + adoptedStyleSheets with adoptedStyleSheets.
This example demonstrates two equivalent methods to import CSS module scripts, the
+ first using the JavaScript import method and the second using the
+ shadowrootadoptedstylesheets
+ attribute.
+<script type="importmap">
+{
+ "imports": {
+ "foo": "data:text/css,div {color:blue}"
+ }
+}
+</script>
+<div id="host">
+ <template shadowrootmode="open">
+ <script type="module">
+ import styles from "foo" with { type: "css"};
+ document.getElementById("host").shadowRoot.adoptedStyleSheets = [styles];
+ </script>
+ <div>test</div>
+ </template>
+</div>
+<div id="host_shadowrootadoptedstylesheets_attribute">
+ <template shadowrootmode="open" shadowrootadoptedstylesheets="foo">
+ <div>test</div>
+ </template>
+</div>
+
+ Note that these two examples are functionally equivalent, but the example with + shadowrootadoptedstylesheets + might initially render without styles applied.
+Set moduleMap[(url,
moduleType)] to "fetching".
If destination is "style", then:
Let emptyStyleScript be the result of creating a CSS module + script with an empty source and settingsObject
set moduleMap[(url,
+ moduleType)] to emptyStyleScript, retaining the "fetching" status.
Let request be a new request whose
URL is url, mode is " If the MIME type essence of mimeType is "cors", text/css"
and moduleType is "css", then set moduleScript to
- the result of creating a CSS module script given sourceText and
- settingsObject.
If mimeType is a JSON MIME type and
moduleType is "json", then set moduleScript to
@@ -117875,6 +117972,32 @@ document.querySelector("button").addEventListener("click", bound);
To update a CSS module script, given a + string source and a script module script :
+ +Let sheet be the default export of script
Run the steps to synchronously replace the rules of a CSSStyleSheet
+ on sheet given source.
If this throws an exception, catch it, and set script's parse error to that exception, and return + script.
+ +The steps to synchronously replace the rules of a
+ CSSStyleSheet will throw if source contains any @import rules. This is by-design for now because there is not yet an
+ agreement on how to handle these for CSS module scripts; therefore they are blocked altogether
+ until a consensus is reached.
Return script.
To create a JSON module script, given a string source and an environment settings object settings:
@@ -140818,6 +140941,10 @@ document.body.appendChild(text); data-x="attr-template-shadowrootcustomelementregistry">shadowrootcustomelementregistry attribute, then set shadow's keep custom element registry null to true. + +If templateStartTag has a shadowrootadoptedstylesheets
+ attribute, then perform the stylesheet adopting steps on template.
If shadow's clonable is set, then append
" shadowrootclonable=""".
If shadow's shadowrootadoptedstylesheets is set, then append
+ the value of shadowrootadoptedstylesheets
Let shouldAppendRegistryAttribute be the result of running these steps:
@@ -152487,7 +152619,8 @@ interface External {shadowrootdelegatesfocus;
shadowrootclonable;
shadowrootserializable;
- shadowrootcustomelementregistry
+ shadowrootcustomelementregistry;
+ shadowrootadoptedstylesheets
HTMLTemplateElementoption
shadowrootadoptedstylesheets
+ template
+ shadowrootclonable
template