Skip to content
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

Update references from "import assertions" to "import attributes" #9069

Merged
merged 2 commits into from
Mar 24, 2023
Merged
Changes from all commits
Commits
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
81 changes: 35 additions & 46 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2926,7 +2926,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>The <dfn data-x="js-HostEnqueuePromiseJob" data-x-href="https://tc39.es/ecma262/#sec-hostenqueuepromisejob">HostEnqueuePromiseJob</dfn> abstract operation</li>
<li>The <dfn data-x="js-HostEnsureCanAddPrivateElement" data-x-href="https://tc39.es/ecma262/#sec-hostensurecanaddprivateelement">HostEnsureCanAddPrivateElement</dfn> abstract operation</li>
<li>The <dfn data-x="js-HostEnsureCanCompileStrings" data-x-href="https://tc39.es/ecma262/#sec-hostensurecancompilestrings">HostEnsureCanCompileStrings</dfn> abstract operation</li>
<li>The <dfn data-x="js-HostLoadImportedModule" data-x-href="https://tc39.es/ecma262/#sec-HostLoadImportedModule">HostLoadImportedModule</dfn> abstract operation</li>
<li>The <dfn data-x="js-HostLoadImportedModule" data-x-href="https://tc39.es/proposal-import-attributes/#sec-HostLoadImportedModule">HostLoadImportedModule</dfn> abstract operation</li>
<li>The <dfn data-x="js-HostMakeJobCallback" data-x-href="https://tc39.es/ecma262/#sec-hostmakejobcallback">HostMakeJobCallback</dfn> abstract operation</li>
<li>The <dfn data-x="js-HostPromiseRejectionTracker" data-x-href="https://tc39.es/ecma262/#sec-host-promise-rejection-tracker">HostPromiseRejectionTracker</dfn> abstract operation</li>
<li>The <dfn data-x="js-InitializeHostDefinedRealm" data-x-href="https://tc39.es/ecma262/#sec-initializehostdefinedrealm">InitializeHostDefinedRealm</dfn> abstract operation</li>
Expand Down Expand Up @@ -2989,13 +2989,13 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<p>Users agents that support JavaScript must also implement <cite>ECMAScript
Internationalization API</cite>. <ref spec=JSINTL></p>

<p>User agents that support JavaScript must also implement the <cite>Import Assertions</cite>
<p>User agents that support JavaScript must also implement the <cite>Import Attributes</cite>
proposal. The following terms are defined there, and used in this specification: <ref
spec=JSIMPORTASSERTIONS></p>
spec=JSIMPORTATTRIBUTES></p>

<ul class="brief">
<li>The <dfn data-x-href="https://tc39.es/proposal-import-assertions/#sec-modulerequest-record">ModuleRequest Record</dfn> specification type</li>
<li>The <dfn data-x="js-HostGetSupportedImportAssertions" data-x-href="https://tc39.es/proposal-import-assertions/#sec-hostgetsupportedimportassertions">HostGetSupportedImportAssertions</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/proposal-import-attributes/#sec-modulerequest-record">ModuleRequest Record</dfn> specification type</li>
<li>The <dfn data-x="js-HostGetSupportedImportAttributes" data-x-href="https://tc39.es/proposal-import-attributes/#sec-hostgetsupportedimportattributes">HostGetSupportedImportAttributes</dfn> abstract operation</li>
</ul>

<p>User agents that support JavaScript must also implement the <cite>JSON modules</cite>
Expand Down Expand Up @@ -60740,7 +60740,7 @@ o............A....e
a <span>JavaScript module script</span>:</p>

<pre><code class="html" data-x="">&lt;script type="module">
import peopleInSpace from "http://api.open-notify.org/astros.json" assert { type: "json" };
import peopleInSpace from "http://api.open-notify.org/astros.json" with { type: "json" };

const list = document.querySelector("#people-in-space");
for (const { craft, name } of peopleInSpace.people) {
Expand All @@ -60753,7 +60753,7 @@ o............A....e
<p>MIME type checking for module scripts is strict. In order for the fetch of the <span>JSON
module script</span> to succeed, the HTTP response must have a <span>JSON MIME type</span>, for
example <code data-x="">Content-Type: text/json</code>. On the other hand, if the <code
data-x="">assert { type: "json" }</code> part of the statement is omitted, it is assumed that the
data-x="">with { type: "json" }</code> part of the statement is omitted, it is assumed that the
intent is to import a <span>JavaScript module script</span>, and the fetch will fail if the HTTP
response has a MIME type that is not a <span>JavaScript MIME type</span>.</p>
</div>
Expand Down Expand Up @@ -98463,7 +98463,7 @@ document.querySelector("button").addEventListener("click", bound);
<li><p><span>Assert</span>: the result of running the <span>module type allowed</span> steps given
<var>moduleType</var> and <var>module map settings object</var> is true. Otherwise we would not
have reached this point because a failure would have been raised when inspecting
<var>moduleRequest</var>.[[Assertions]] in <a href="#validate-requested-module-specifiers">create
<var>moduleRequest</var>.[[Attributes]] in <a href="#validate-requested-module-specifiers">create
a JavaScript module script</a> or <span>fetch a single imported module script</span>.</p></li>

<li><p>Let <var>moduleMap</var> be <var>module map settings object</var>'s <span
Expand Down Expand Up @@ -98584,10 +98584,10 @@ document.querySelector("button").addEventListener("click", bound);
<span>module script</span> (on success).</p>

<ol>
<li><p><span>Assert</span>: <var>moduleRequest</var>.[[Assertions]] does not contain any <span>Record</span>
<li><p><span>Assert</span>: <var>moduleRequest</var>.[[Attributes]] does not contain any <span>Record</span>
<var>entry</var> such that <var>entry</var>.[[Key]] is not "<code data-x="">type</code>", because
we only asked for "<code data-x="">type</code>" assertions in
<span>HostGetSupportedImportAssertions</span>.</p></li>
we only asked for "<code data-x="">type</code>" attributes in
<span>HostGetSupportedImportAttributes</span>.</p></li>

<li><p>Let <var>moduleType</var> be the result of running the <span>module type from module
request</span> steps given <var>moduleRequest</var>.</p></li>
Expand Down Expand Up @@ -98709,10 +98709,10 @@ document.querySelector("button").addEventListener("click", bound);
</ol>
</li>

<li><p><span>Assert</span>: <var>requested</var>.[[Assertions]] does not contain any
<li><p><span>Assert</span>: <var>requested</var>.[[Attributes]] does not contain any
<span>Record</span> <var>entry</var> such that <var>entry</var>.[[Key]] is not "<code
data-x="">type</code>", because we only asked for "<code data-x="">type</code>" assertions in
<span>HostGetSupportedImportAssertions</span>.</p></li>
data-x="">type</code>", because we only asked for "<code data-x="">type</code>" attributes in
<span>HostGetSupportedImportAttributes</span>.</p></li>

<li id="validate-requested-module-specifiers">
<p><span data-x="list iterate">For each</span> <span>ModuleRequest record</span>
Expand Down Expand Up @@ -98753,8 +98753,8 @@ document.querySelector("button").addEventListener("click", bound);
</ol>

<p class="note">This step is essentially validating all of the requested module specifiers and
type assertions. We treat a module with unresolvable module specifiers or unsupported type
assertions the same as one that cannot be parsed; in both cases, a syntactic issue makes it
type attributes. We treat a module with unresolvable module specifiers or unsupported type
attributes the same as one that cannot be parsed; in both cases, a syntactic issue makes it
impossible to ever contemplate linking the module later.</p>
</li>

Expand Down Expand Up @@ -98839,7 +98839,7 @@ document.querySelector("button").addEventListener("click", bound);
<li><p>Let <var>moduleType</var> be "<code data-x="">javascript</code>".</p></li>

<li>
<p>If <var>moduleRequest</var>.[[Assertions]] has a <span>Record</span> <var>entry</var> such
<p>If <var>moduleRequest</var>.[[Attributes]] has a <span>Record</span> <var>entry</var> such
that <var>entry</var>.[[Key]] is "<code data-x="">type</code>", then:</p>

<ol>
Expand All @@ -98850,7 +98850,7 @@ document.querySelector("button").addEventListener("click", bound);
<p class="note">This specification uses the "<code data-x="">javascript</code>" module type
internally for <span data-x="JavaScript module script">JavaScript module scripts</span>, so
this step is needed to prevent modules from being imported using a "<code
data-x="">javascript</code>" type assertion (a null <var>moduleType</var> will cause the
data-x="">javascript</code>" type attribute (a null <var>moduleType</var> will cause the
<span>module type allowed</span> check to fail).</p>
</li>

Expand Down Expand Up @@ -100609,15 +100609,10 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
import "https://example.com/module";
&lt;/script&gt;
&lt;script type=module&gt;
import "https://example.com/module" assert { type: "css" };
import "https://example.com/module" with { type: "css" };
&lt;/script&gt;</code></pre>

<p>This can result in two separate fetches and two separate module evaluations being performed.
This is a <span>willful violation</span> of a constraint recommended (but not required) by the
import assertions specification stating that each call to <span>HostLoadImportedModule</span>
with the same (<var>referrer</var>, <var>moduleRequest</var>.[[Specifier]]) pair
must return the same <span data-x="Source Text Module Record">Module Record</span>. <ref
spec=JSIMPORTASSERTIONS></p>
<p>This can result in two separate fetches and two separate module evaluations being performed.</p>

<p class="XXX">In practice, due to the as-yet-unspecified memory cache (see issue <a
href="https://github.com/whatwg/html/issues/6110">#6110</a>) the resource may only be fetched
Expand All @@ -100626,26 +100621,26 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
least one of the imports, so at most one module evaluation will occur.</p>

<p>The purpose of including the type in the <span>module map</span> key is so that an import
with the wrong type assertion does not prevent a different import of the same specifier but with
with the wrong type attribute does not prevent a different import of the same specifier but with
the correct type from succeeding.</p>
</div>

<div class="example">
<p>JavaScript module scripts are the default import type when importing from another JavaScript
module; that is, when an <code data-x="">import</code> statement lacks a <code
data-x="">type</code> import assertion the imported module script's type will be JavaScript.
data-x="">type</code> import attribute the imported module script's type will be JavaScript.
Attempting to import a JavaScript resource using an <code data-x="">import</code> statement with
a <code data-x="">type</code> import assertion will fail:</p>
a <code data-x="">type</code> import attribute will fail:</p>

<pre><code class="html">&lt;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 } });
// any import type attribute.
import foo from "./foo.mjs" with { type: "javascript" };
import foo2 from "./foo2.mjs" with { type: "js" };
import foo3 from "./foo3.mjs" with { type: "" };
await import("./foo4.mjs", { with: { type: null } });
await import("./foo5.mjs", { with: { type: undefined } });
&lt;/script></code></pre>
</div>

Expand Down Expand Up @@ -100693,12 +100688,12 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
».</p></li>
</ol>

<h6 id="hostgetsupportedimportassertions"><dfn>HostGetSupportedImportAssertions</dfn>()</h6>
<h6 id="hostgetsupportedimportattributes"><span id="hostgetsupportedimportassertions"></span><dfn>HostGetSupportedImportAttributes</dfn>()</h6>

<p>The <cite>Import Assertions</cite> proposal contains an <span>implementation-defined</span>
<span data-x="js-HostGetSupportedImportAssertions">HostGetSupportedImportAssertions</span>
<p>The <cite>Import Attributes</cite> proposal contains an <span>implementation-defined</span>
<span data-x="js-HostGetSupportedImportAttributes">HostGetSupportedImportAttributes</span>
abstract operation. User agents must use the following implementation: <ref
spec=JSIMPORTASSERTIONS></p>
spec=JSIMPORTATTRIBUTES></p>

<ol>
<li><p>Return « "<code data-x="">type</code>" ».</p></li>
Expand All @@ -100711,12 +100706,6 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
data-x="js-HostLoadImportedModule">HostLoadImportedModule</span> abstract operation. User agents
must use the following implementation: <ref spec=JAVASCRIPT></p>

<p class="note">This specification expects the second parameter to be a <span>ModuleRequest
Record</span>, instead of a string as specified by ECMA-262. This is under the assumption that the
<cite>import assertions</cite> proposal, when updated to use <span>HostLoadImportedModule</span>
instead of the previous module loading hooks, will update the abstract operation passing a
<span>ModuleRequest Record</span>. <ref spec=JSIMPORTASSERTIONS></p>

<ol>
<li><p>Let <var>settingsObject</var> be the <span>current settings object</span>.</p></li>

Expand Down Expand Up @@ -133208,8 +133197,8 @@ INSERT INTERFACES HERE
<dt id="refsJSERRORSTACKS">[JSERRORSTACKS]</dt>
<dd>(Non-normative) <cite><a href="https://tc39.es/proposal-error-stacks/">Error Stacks</a></cite>. Ecma International.</dd>

<dt id="refsJSIMPORTASSERTIONS">[JSIMPORTASSERTIONS]</dt>
<dd><cite><a href="https://tc39.es/proposal-import-assertions/">Import Assertions</a></cite>. Ecma International.</dd>
<dt id="refsJSIMPORTATTRIBUTES">[JSIMPORTATTRIBUTES]</dt>
<dd><cite><a href="https://tc39.es/proposal-import-attributes/">Import attributes</a></cite>. Ecma International.</dd>

<dt id="refsJSJSONMODULES">[JSJSONMODULES]</dt>
<dd><cite><a href="https://tc39.es/proposal-json-modules/">JSON Modules</a></cite>. Ecma International.</dd>
Expand Down