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

Replace invalid import attributes assertion #9599

Merged
merged 4 commits into from
Aug 23, 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
27 changes: 22 additions & 5 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -3034,6 +3034,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-finalization-registry-objects"><code>FinalizationRegistry</code></dfn> class</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-regexp-regular-expression-objects"><code>RegExp</code></dfn> class</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-sharedarraybuffer-objects"><code>SharedArrayBuffer</code></dfn> class</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-syntaxerror"><code>SyntaxError</code></dfn> class</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror"><code>TypeError</code></dfn> class</li>
<li>The <dfn data-x="js-RangeError" data-x-href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror"><code>RangeError</code></dfn> class</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-weak-ref-objects"><code>WeakRef</code></dfn> class</li>
Expand Down Expand Up @@ -103806,16 +103807,32 @@ document.querySelector("button").addEventListener("click", bound);
</ol>
nicolo-ribaudo marked this conversation as resolved.
Show resolved Hide resolved
</li>

<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>" 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>
<var>requested</var> of <var>result</var>.[[RequestedModules]]:</p>

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

<ol>
<li><p>Let <var>error</var> be a new <code>SyntaxError</code> exception.</p></li>

<li><p>Set <var>script</var>'s <span data-x="concept-script-parse-error">parse error</span>
to <var>error</var>.</p></li>

<li><p>Return <var>script</var>.</p></li>
</ol>

<p class="note">The JavaScript specification re-performs this validation when loading
<var>script</var>'s dependencies. It is duplicated here to skip unnecessary work given that,
in case of an invalid attribute key, loading the module graph would fail anyway. Additionally,
this makes the errors reported for invalid static imports consistent with dynamic imports, for
which invalid attributes are reported before calling into HTML and thus before validating the
imported specifier.</p>
</li>

<li><p><span>Resolve a module specifier</span> given <var>script</var> and
<var>requested</var>.[[Specifier]], catching any exceptions.</p></li>

Expand Down