diff --git a/source b/source index 3d1ea201404..8b87e1ec9c6 100644 --- a/source +++ b/source @@ -2778,7 +2778,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
RequestCredentials
enumerationRequestDestination
enumerationfetch()
methodSetting the attribute to an ASCII case-insensitive match for the string
- "module
" means that the script is a module script.
- If it has a JavaScript MIME type, or if the script is embedded inline, then it will
- be interpreted as a JavaScript module script according to the JavaScript Module top-level production. Module scripts are not affected by
- the defer
attribute, but are affected by the async
attribute (regardless of the state of the src
attribute).
module
" means that the script is a module script. If it has
+ a JavaScript MIME type, or if the script is embedded inline, then it will be
+ interpreted as a JavaScript module script according to the JavaScript Module top-level production; if it has a JSON MIME
+ type, then it will be interpreted as a JSON module script. Module scripts
+ are not affected by the defer
attribute, but are
+ affected by the async
attribute (regardless of the state
+ of the src
attribute).
Setting the attribute to any other value means that the script is a data
block, which is not processed. None of the script
attributes (except HTMLScriptElement : HTMLElement {
ever be reinterpreted as a different script type, even in future user agents.
Classic scripts and JavaScript module scripts may be embedded inline, and all script types may be
- imported from an external file using the src
attribute, which if
- specified gives the URL of the external script resource to use. If src
is specified, it must be a valid non-empty URL
- potentially surrounded by spaces. The contents of inline script
elements,
- or the external script resource, must conform with the requirements of the JavaScript
- specification's Script or Module
- productions, for classic scripts and
- JavaScript module scripts respectively.
-
The external script resource of JSON module scripts - must conform to the requirements of the JSON specification .
+ script">JavaScript module scripts can be embedded inline, or be imported from an external + file using thesrc
attribute, which if specified gives the URL
+ of the external script resource to use. If src
is specified,
+ it must be a valid non-empty URL potentially surrounded by spaces.
+
+ The contents of inline script
elements, or the external script resource, must
+ conform with the requirements of the JavaScript specification's Script or Module productions, for classic scripts and JavaScript module scripts respectively.
The contents of the external script resource for JSON module + scripts must conform to the requirements of the JSON specification .
When used to include data blocks, the data must be embedded
inline, the format of the data must be given using the type
@@ -58132,6 +58132,24 @@ o............A....e
+
The following sample shows how to you can import a JSON module script from inside + a JavaScript module script:
+ +<script type="module">
+import peopleInSpace from "http://api.open-notify.org/astros.json";
+
+const list = document.querySelector("#people-in-space");
+for (const { craft, name } of peopleInSpace.people) {
+ const li = document.createElement("li");
+ li.textContent = `${name} / ${craft}`;
+ list.append(li);
+}
+</script>
+
+ a script record, for classic - scripts
a Source Text Module Record, for JavaScript module scripts
a Synthetic Module Record, for JSON module - scripts
a Synthetic Module Record, for JSON + module scripts; or
null, representing a parsing failure.
This specification defines multiple types of module scripts. None of these have additional - items.
+Module scripts can be classified into two types:
A JavaScript module script represents a JavaScript Source - Text Module Record.
A JSON module script represents a parsed JSON document. - As JSON documents do import dependent modules and do not throw exceptions on execution, - the fetch options and base URL of a JSON module script - are always null.
A module script is a JavaScript module script if + its record is a Source Text Module + Record.
A module script is a JSON module script if its record is a Synthetic Module Record, and it + was created via the create a JSON module + script algorithm. JSON module scripts represent a parsed JSON document.
+ + +As JSON documents do not import dependent modules, and do not throw exceptions + on evaluation, the fetch options and + base URL of a JSON module script are + always null.
+The active script is determined by the following algorithm:
@@ -87422,7 +87455,8 @@ interface ApplicationCache : EventTarget {Let module script be null.
If the resource does not have a MIME type which HTML knows how to handle - as a module, then module script will be null, which is interpreted as failure.
+ as a module, then module script will remain null, which is interpreted as + failure.Let script be a new JSON module script that this algorithm will +
Let script be a new module script that this algorithm will subsequently initialize.
Set script's settings object to settings.