From 0b21a83d6b9305f8c4ad172528ab804a57d7cb05 Mon Sep 17 00:00:00 2001
From: Dan Clark type" assertions in
HostGetSupportedImportAssertions.
If moduleRequest.[[Assertions]] has a Record entry
- such that entry.[[Key]] is "type", then let module
- type be entry.[[Value]]. Otherwise let module type be "javascript".
Let module type be the result of running the module type from module + request steps given moduleRequest.
If the result of running the module type allowed steps given module type and settings object is false, then asynchronously complete this algorithm @@ -91741,10 +91739,8 @@ document.querySelector("button").addEventListener("click", bound); href="#validate-requested-module-specifiers">previously successful with these same two arguments.
If requested.[[Assertions]] has a Record entry such
- that entry.[[Key]] is "type", then let module type
- be entry.[[Value]]. Otherwise let module type be "javascript".
Let module type be the result of running the module type from module + request steps given requested.
If visited set does not contain @@ -91807,10 +91803,8 @@ document.querySelector("button").addEventListener("click", bound); href="#validate-requested-module-specifiers">previously successful with these same two arguments.
If moduleRequest.[[Assertions]] has a Record entry
- such that entry.[[Key]] is "type", then let module
- type be entry.[[Value]]. Otherwise let module type be "javascript".
Let module type be the result of running the module type from module + request steps given moduleRequest.
Assert: visited set contains (url, module type).
Let module type be "javascript".
If moduleRequest was given and moduleRequest.[[Assertions]] has a
- Record entry such that entry.[[Key]] is "type", then:
Assert: No more than one such Record exists.
Set module type to entry.[[Value]].
If moduleRequest was given, then set module type to the result of + running the module type from module request steps given + moduleRequest.
Assert: the result of running the module type allowed steps given module type and module map settings object is true. Otherwise we would not have reached @@ -92004,10 +91990,8 @@ document.querySelector("button").addEventListener("click", bound); href="#validate-requested-module-specifiers">marked as itself having a parse error.)
If moduleRequest.[[Assertions]] has a Record entry
- such that entry.[[Key]] is "type", then let module
- type be entry.[[Value]]. Otherwise let module type be "javascript".
Let module type be the result of running the module type from module + request steps given moduleRequest.
Let childModule be moduleMap[(childURL, module type)].
If requested.[[Assertions]] has a Record entry such
- that entry.[[Key]] is "type", then let module type
- be entry.[[Value]]. Otherwise let module type be "javascript".
Let module type be the result of running the module type from module + request steps given requested.
If url is failure, or if the result of running the module type
@@ -92252,6 +92234,34 @@ document.querySelector("button").addEventListener("click", bound);
Return script.
The module type from module request steps, given a ModuleRequest + Record moduleRequest, are as follows:
+ +Let module type be "javascript".
If moduleRequest.[[Assertions]] has a Record entry such
+ that entry.[[Key]] is "type", then:
If entry.[[Value]] is "javascript", then set
+ module type to null.
This specification uses the "javascript" module type
+ internally for JavaScript module scripts, so
+ this step is needed to prevent modules from being imported using a "javascript" type assertion.
Otherwise, set module type to entry.[[Value]].
Return module type.
The module type allowed steps, given a string module type and an environment settings object settings, are as follows:
From 1166785cf9538ba0cb3f0a2a8b46d4bd5156b2fc Mon Sep 17 00:00:00 2001 From: Dan ClarkThis specification uses the "javascript" module type
internally for JavaScript module scripts, so
this step is needed to prevent modules from being imported using a "javascript" type assertion.
Otherwise, set module type to entry.[[Value]].
type" assertions in
HostGetSupportedImportAssertions.
- Let module type be the result of running the module type from module
+ Let moduleType be the result of running the module type from module
request steps given moduleRequest. If the result of running the module type allowed steps given module
- type and settings object is false, then asynchronously complete this algorithm
- with null, and return. If the result of running the module type allowed steps given
+ moduleType and settings object is false, then asynchronously complete this
+ algorithm with null, and return. Fetch a single module script given url, settings
object, " If result is null, asynchronously complete this algorithm with null, and
return. Let visited set be « (url, module type) ». Let visited set be « (url, moduleType) ». Fetch the
descendants of and link result given settings object,
@@ -91739,18 +91739,18 @@ document.querySelector("button").addEventListener("click", bound);
href="#validate-requested-module-specifiers">previously successful with these same two
arguments. Let module type be the result of running the module type from module
+ Let moduleType be the result of running the module type from module
request steps given requested. If visited set does not contain
- (url, module type), then: Append requested to
moduleRequests. Append (url, module type) to
+ Append (url, moduleType) to
visited set.script", options, settings object,
@@ -91391,7 +91391,7 @@ document.querySelector("button").addEventListener("click", bound);
Let module type be the result of running the module type from module
+ Let moduleType be the result of running the module type from module
request steps given moduleRequest. Assert: visited set contains
- (url, module type).
Fetch a single module script given url, fetch client settings object, destination, options, module map settings object, @@ -91838,15 +91838,15 @@ document.querySelector("button").addEventListener("click", bound); complete with either null (on failure) or a module script (on success).
Let module type be "javascript".
Let moduleType be "javascript".
If moduleRequest was given, then set module type to the result of +
If moduleRequest was given, then set moduleType to the result of running the module type from module request steps given moduleRequest.
Assert: the result of running the module type allowed steps given module - type and module map settings object is true. Otherwise we would not have reached - this point because a failure would have been raised when inspecting +
Assert: the result of running the module type allowed steps given + moduleType and module map settings object is true. Otherwise we would not + have reached this point because a failure would have been raised when inspecting moduleRequest.[[Assertions]] in create a JavaScript module script or fetch an import() module script graph.
Let moduleMap be module map settings object's module map.
If moduleMap[(url, module type)] is +
If moduleMap[(url, moduleType)] is
"fetching", wait in parallel until that entry's value
changes, then queue a task on the networking task source to proceed
with running the following steps.
If moduleMap[(url, module type)] If moduleMap[(url, moduleType)] exists, asynchronously complete this algorithm with
- moduleMap[url / module type], and return.
Set moduleMap[(url, module
- type)] to "fetching".
Set moduleMap[(url,
+ moduleType)] to "fetching".
Let request be a new request whose URL is url, ok status.
then set moduleMap[(url, module - type)] to null, asynchronously complete this algorithm with null, and return.
+then set moduleMap[(url, + moduleType)] to null, asynchronously complete this algorithm with null, and + return.
Let source text be the result of UTF-8
@@ -91927,26 +91928,26 @@ document.querySelector("button").addEventListener("click", bound);
Let module script be null. If MIME type is a JavaScript MIME type and module type
+ If MIME type is a JavaScript MIME type and moduleType
is " If the MIME type essence of MIME type is " If MIME type essence is a JSON MIME type and module
- type is " If MIME type essence is a JSON MIME type and moduleType
+ is " Set moduleMap[(url, module
- type)] to module script, and asynchronously complete this algorithm with
- module script. Set moduleMap[(url,
+ moduleType)] to module script, and asynchronously complete this algorithm
+ with module script. It is intentional that the module map is keyed by the request URL, whereas the marked as itself having a parse
error.) Let module type be the result of running the module type from module
+ Let moduleType be the result of running the module type from module
request steps given moduleRequest. Let childModule be moduleMap[(childURL, module
- type)]. Let childModule be moduleMap[(childURL,
+ moduleType)]. Assert: childModule is a module script (i.e., it is not " Let module type be the result of running the module type from module
+ Let moduleType be the result of running the module type from module
request steps given requested. If url is failure, or if the result of running the module type
- allowed steps given module type and settings is false, then: Let error be a new Let module type be " Let moduleType be " If moduleRequest.[[Assertions]] has a Record entry such
@@ -92247,30 +92248,30 @@ document.querySelector("button").addEventListener("click", bound);
If entry.[[Value]] is "javascript", then set module script to the result of
creating a JavaScript module script given source text, module map
settings object, response's url, and
options.text/css"
- and module type is "css", then set module script to
+ and moduleType is "css", then set module script to
the result of creating a CSS module script given source text and
module map settings object.json", then set module script to the result of
+ json", then set module script to the result of
creating a JSON module script given source text and module map
settings object.fetching" or null); by now all module
@@ -92137,12 +92138,12 @@ document.querySelector("button").addEventListener("click", bound);
a module specifier given script's base
URL and requested.[[Specifier]].
TypeError exception.
-
javascript".javascript".
javascript", then set
- module type to null.
This specification uses the "javascript" module type
internally for JavaScript module scripts, so
this step is needed to prevent modules from being imported using a "javascript" type assertion (a null module type will cause the
+ data-x="">javascript" type assertion (a null moduleType will cause the
module type allowed check to fail).
Otherwise, set module type to entry.[[Value]].
Otherwise, set moduleType to entry.[[Value]].
Return module type.
Return moduleType.
The module type allowed steps, given a string module type +
The module type allowed steps, given a string moduleType and an environment settings object settings, are as follows:
If module type is not " If moduleType is not "javascript", "javascript", "css", or "json", then return false.
If module type is "css" and the
+
If moduleType is "css" and the
CSSStyleSheet interface is not exposed in
setting's Realm, then
return false.
If moduleRequest.[[Assertions]] has a Record entry such
- that entry.[[Key]] is "type", then let module type
- be entry.[[Value]]. Otherwise let module type be "entry.[[Key]] is "type", then let moduleType
+ be entry.[[Value]]. Otherwise let moduleType be "javascript".
Let resolved module script be moduleMap[(url, module - type)]. (This entry must exist for us to have gotten to - this point.)
Let resolved module script be moduleMap[(url, + moduleType)]. (This entry must exist for us to have + gotten to this point.)
Assert: resolved module script is a module script (i.e., is not
null or "fetching").
If moduleRequest.[[Assertions]] has a Record entry such
- that entry.[[Key]] is "type", then let moduleType
- be entry.[[Value]]. Otherwise let moduleType be "javascript".
Let moduleType be the result of running the module type from module + request steps given moduleRequest.
Let resolved module script be moduleMap[(url,
moduleType)]. (This entry must exist for us to have
From 0bcfc126a13e69d91de7bdf23e634d11a0941fac Mon Sep 17 00:00:00 2001
From: Dan Clark script element appears in the document, it will not be evaluated until
both document parsing has complete and its dependency (dom-utils.mjs) has
been fetched and evaluated.
JavaScript module scripts are the default import type when importing from another JavaScript + module; that is, when an import statement lacks a "type" import assertion the import's type will + be JavaScript. Attempting to import a JavaScript resource using an import statement with a "type" + import assertion will fai:
+ +<script type="module">
+ // All of the following will fail, assuming that the imported mjs files are served with a
+ // JavaScript MIME type. JavaScript module scripts are the default and cannot be imported with
+ // any import assertion.
+ import foo from "./bar.mjs" assert { type: "javascript" };
+ import foo2 from "./bar2.mjs" assert { type: "js" };
+ import foo3 from "./bar3.mjs" assert { type: "" };
+ await import("./bar4.mjs", { assert: { type: null } });
+</script>
JavaScript module scripts are the default import type when importing from another JavaScript module; that is, when an import statement lacks a "type" import assertion the import's type will be JavaScript. Attempting to import a JavaScript resource using an import statement with a "type" - import assertion will fai:
+ import assertion will fail:<script type="module">
- // All of the following will fail, assuming that the imported mjs files are served with a
+ // All of the following will fail, assuming that the imported .mjs files are served with a
// JavaScript MIME type. JavaScript module scripts are the default and cannot be imported with
- // any import assertion.
+ // any import type assertion.
import foo from "./bar.mjs" assert { type: "javascript" };
import foo2 from "./bar2.mjs" assert { type: "js" };
import foo3 from "./bar3.mjs" assert { type: "" };
From 64f51097521b8a83d41d35fefbe590052e5b68a9 Mon Sep 17 00:00:00 2001
From: Dan Clark
Date: Tue, 23 Nov 2021 10:14:31 -0800
Subject: [PATCH 07/10] Add 'undefined' type assertion example
---
source | 1 +
1 file changed, 1 insertion(+)
diff --git a/source b/source
index c8aa3970e97..c04cc72893d 100644
--- a/source
+++ b/source
@@ -58815,6 +58815,7 @@ o............A....e
import foo2 from "./bar2.mjs" assert { type: "js" };
import foo3 from "./bar3.mjs" assert { type: "" };
await import("./bar4.mjs", { assert: { type: null } });
+ await import("./bar5.mjs", { assert: { type: undefined } });
</script>
If moduleType is "css" and the
CSSStyleSheet interface is not exposed in
- setting's Realm, then
+ settings's Realm, then
return false.
Return true.
styling where appropriate.
---
source | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/source b/source
index 3c76975df40..dace02e8481 100644
--- a/source
+++ b/source
@@ -58801,22 +58801,6 @@ o............A....e
where this script element appears in the document, it will not be evaluated until
both document parsing has complete and its dependency (dom-utils.mjs) has
been fetched and evaluated.
-
- JavaScript module scripts are the default import type when importing from another JavaScript
- module; that is, when an import statement lacks a "type" import assertion the import's type will
- be JavaScript. Attempting to import a JavaScript resource using an import statement with a "type"
- import assertion will fail:
-
- <script type="module">
- // All of the following will fail, assuming that the imported .mjs files are served with a
- // JavaScript MIME type. JavaScript module scripts are the default and cannot be imported with
- // any import type assertion.
- import foo from "./bar.mjs" assert { type: "javascript" };
- import foo2 from "./bar2.mjs" assert { type: "js" };
- import foo3 from "./bar3.mjs" assert { type: "" };
- await import("./bar4.mjs", { assert: { type: null } });
- await import("./bar5.mjs", { assert: { type: undefined } });
-</script>
@@ -93192,6 +93176,25 @@ import "https://example.com/foo/../module2.mjs";
the correct type from succeeding.
+
+ JavaScript module scripts are the default import type when importing from another JavaScript
+ module; that is, when an import statement lacks a type import assertion the import's type will be
+ JavaScript. Attempting to import a JavaScript resource using an import
+ statement with a type import assertion will fail:
+
+ <script type="module">
+ // All of the following will fail, assuming that the imported .mjs files are served with a
+ // JavaScript MIME type. JavaScript module scripts are the default and cannot be imported with
+ // any import type assertion.
+ import foo from "./foo.mjs" assert { type: "javascript" };
+ import foo2 from "./foo2.mjs" assert { type: "js" };
+ import foo3 from "./foo3.mjs" assert { type: "" };
+ await import("./foo4.mjs", { assert: { type: null } });
+ await import("./foo5.mjs", { assert: { type: undefined } });
+</script>
+
+
To resolve a module specifier given a URL base URL and a
From a7ff72672b53acc5e3f74416d51ad3b072fc2bb8 Mon Sep 17 00:00:00 2001
From: Domenic Denicola
Date: Tue, 23 Nov 2021 16:11:00 -0500
Subject: [PATCH 10/10] Nit
---
source | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/source b/source
index dace02e8481..79148642b9a 100644
--- a/source
+++ b/source
@@ -93179,9 +93179,9 @@ import "https://example.com/foo/../module2.mjs";
JavaScript module scripts are the default import type when importing from another JavaScript
module; that is, when an import statement lacks a type import assertion the import's type will be
- JavaScript. Attempting to import a JavaScript resource using an import
- statement with a type import assertion will fail:
+ data-x="">type import assertion the imported module script's type will be JavaScript.
+ Attempting to import a JavaScript resource using an import statement with
+ a type import assertion will fail:
<script type="module">
// All of the following will fail, assuming that the imported .mjs files are served with a