Skip to content

Commit fee73fa

Browse files
littledandomenicMs2ger
authored
Top-level await integration
Integrates HTML with the JavaScript top-level await feature: https://github.com/tc39/proposal-top-level-await Co-authored-by: Domenic Denicola <[email protected]> Co-authored-by: Ms2ger <[email protected]>
1 parent 009a731 commit fee73fa

File tree

1 file changed

+30
-49
lines changed

1 file changed

+30
-49
lines changed

source

Lines changed: 30 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,6 +2654,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
26542654
sequence of Unicode scalar values</dfn></li>
26552655
<li><dfn data-x-href="https://heycam.github.io/webidl/#dfn-overload-resolution-algorithm">overload resolution algorithm</dfn></li>
26562656
<li><dfn data-x="idl-exposed" data-x-href="https://heycam.github.io/webidl/#dfn-exposed">exposed</dfn></li>
2657+
<li><dfn data-x-href="https://heycam.github.io/webidl/#a-promise-rejected-with">a promise rejected with</dfn></li>
2658+
<li><dfn data-x-href="https://heycam.github.io/webidl/#upon-rejection">upon rejection</dfn></li>
26572659
<li><dfn data-x="LegacyFactoryFunction" data-x-href="https://heycam.github.io/webidl/#LegacyFactoryFunction"><code>[LegacyFactoryFunction]</code></dfn></li>
26582660
<li><dfn data-x="LegacyLenientThis" data-x-href="https://heycam.github.io/webidl/#LegacyLenientThis"><code>[LegacyLenientThis]</code></dfn></li>
26592661
<li><dfn data-x="LegacyNullToEmptyString" data-x-href="https://heycam.github.io/webidl/#LegacyNullToEmptyString"><code>[LegacyNullToEmptyString]</code></dfn></li>
@@ -2867,6 +2869,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
28672869

28682870
<p>Users agents that support JavaScript must also implement <cite>ECMAScript
28692871
Internationalization API</cite>. <ref spec=JSINTL></p>
2872+
2873+
<p>User agents that support JavaScript must also implement the <cite>Top-Level Await</cite>
2874+
proposal. <ref spec=JSTLA></p>
28702875
</dd>
28712876

28722877

@@ -89007,11 +89012,9 @@ document.querySelector("button").addEventListener("click", bound);
8900789012
<h5 id="calling-scripts">Calling scripts</h5>
8900889013

8900989014
<p>To <dfn export>run a classic script</dfn> given a <span>classic script</span> <var>script</var>
89010-
and an optional <var>rethrow errors</var> boolean:</p>
89015+
and an optional boolean <var>rethrow errors</var> (default false):</p>
8901189016

8901289017
<ol>
89013-
<li><p>If <var>rethrow errors</var> is not given, let it be false.</p></li>
89014-
8901589018
<li><p>Let <var>settings</var> be the <span>settings object</span> of <var>script</var>.</p></li>
8901689019

8901789020
<li><p><span>Check if we can run script</span> with <var>settings</var>. If this returns "do
@@ -89088,25 +89091,23 @@ document.querySelector("button").addEventListener("click", bound);
8908889091
</p></li>
8908989092
</ol>
8909089093

89091-
<p>To <dfn export>run a module script</dfn> given a <span>module script</span> <var>script</var>,
89092-
with an optional <var>rethrow errors</var> boolean:</p>
89094+
<p>To <dfn export>run a module script</dfn> given a <span>module script</span> <var>script</var>
89095+
and an optional boolean <var>preventErrorReporting</var> (default false):</p>
8909389096

8909489097
<ol>
89095-
<li><p>If <var>rethrow errors</var> is not given, let it be false.</p></li>
89096-
8909789098
<li><p>Let <var>settings</var> be the <span>settings object</span> of <var>script</var>.</p></li>
8909889099

8909989100
<li><p><span>Check if we can run script</span> with <var>settings</var>. If this returns "do
89100-
not run" then return <span>NormalCompletion</span>(empty).</p></li>
89101+
not run", then return a promise resolved with undefined.</p></li>
8910189102

8910289103
<li><p><span>Prepare to run script</span> given <var>settings</var>.</p></li>
8910389104

89104-
<li><p>Let <var>evaluationStatus</var> be null.</p></li>
89105+
<li><p>Let <var>evaluationPromise</var> be null.</p></li>
8910589106

8910689107
<li><p>If <var>script</var>'s <span data-x="concept-script-error-to-rethrow">error to
89107-
rethrow</span> is not null, then set <var>evaluationStatus</var> to Completion { [[Type]]: throw,
89108-
[[Value]]: <var>script</var>'s <span data-x="concept-script-error-to-rethrow">error to
89109-
rethrow</span>, [[Target]]: empty }.</p></li>
89108+
rethrow</span> is not null, then set <var>evaluationPromise</var> to <span>a promise rejected
89109+
with</span> <var>script</var>'s <span data-x="concept-script-error-to-rethrow">error to
89110+
rethrow</span>.</p></li>
8911089111

8911189112
<li>
8911289113
<p>Otherwise:</p>
@@ -89116,35 +89117,26 @@ document.querySelector("button").addEventListener("click", bound);
8911689117
data-x="concept-script-record">record</span>.</p>
8911789118

8911889119
<li>
89119-
<p>Set <var>evaluationStatus</var> to <var>record</var>.<span
89120+
<p>Set <var>evaluationPromise</var> to <var>record</var>.<span
8912089121
data-x="js-Evaluate">Evaluate</span>().</p>
8912189122

8912289123
<p class="note">This step will recursively evaluate all of the module's dependencies.</p>
8912389124

8912489125
<p>If <span data-x="js-Evaluate">Evaluate</span> fails to complete as a result of the user agent
8912589126
<span data-x="abort a running script">aborting the running script</span>, then set
89126-
<var>evaluationStatus</var> to Completion { [[Type]]: throw, [[Value]]: a new
89127-
<span>"<code>QuotaExceededError</code>"</span> <code>DOMException</code>, [[Target]]: empty
89128-
}.</p>
89127+
<var>evaluationPromise</var> to <span>a promise rejected with</span> a new
89128+
<span>"<code>QuotaExceededError</code>"</span> <code>DOMException</code>.</p>
8912989129
</li>
8913089130
</ol>
8913189131
</li>
8913289132

89133-
<li>
89134-
<p>If <var>evaluationStatus</var> is an <span>abrupt completion</span>, then:</p>
89135-
89136-
<ol>
89137-
<li><p>If <var>rethrow errors</var> is true, rethrow the exception given by
89138-
<var>evaluationStatus</var>.[[Value]].</p></li>
89139-
89140-
<li><p>Otherwise, <span>report the exception</span> given by
89141-
<var>evaluationStatus</var>.[[Value]] for <var>script</var>.</p></li>
89142-
</ol>
89143-
</li>
89133+
<li><p>If <var>preventErrorReporting</var> is false, then <span>upon rejection</span> of
89134+
<var>evaluationPromise</var> with <var>reason</var>, <span>report the exception</span> given by
89135+
<var>reason</var> for <var>script</var>.</p></li>
8914489136

8914589137
<li><p><span>Clean up after running script</span> with <var>settings</var>.</p></li>
8914689138

89147-
<li><p>Return <var>evaluationStatus</var>.</p></li>
89139+
<li><p>Return <var>evaluationPromise</var>.</p></li>
8914889140
</ol>
8914989141

8915089142
<p>The steps to <dfn>check if we can run script</dfn> with an <span>environment settings
@@ -89912,30 +89904,16 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
8991289904
URL</var>, <var>settings object</var>, and <var>fetch options</var>. Wait until the algorithm
8991389905
asynchronously completes with <var>result</var>.</p></li>
8991489906

89915-
<li>
89916-
<p>If <var>result</var> is null, then:</p>
89917-
89918-
<ol>
89919-
<li><p>Let <var>completion</var> be Completion { [[Type]]: throw, [[Value]]: a new
89920-
<code>TypeError</code>, [[Target]]: empty }.</p></li>
89921-
89922-
<li><p>Perform <span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>,
89923-
<var>specifier</var>, <var>promiseCapability</var>, <var>completion</var>).</p></li>
89907+
<li><p>Let <var>promise</var> be null.
8992489908

89925-
<li><p>Return.</p></li>
89926-
</ol>
89927-
</li>
89928-
89929-
<li><p><span data-x="run a module script">Run the module script</span> <var>result</var>, with
89930-
the rethrow errors boolean set to true.</p></li>
89909+
<li><p>If <var>result</var> is null, then set <var>promise</var> to <span>a promise rejected
89910+
with</span> a new <code>TypeError</code>.</p></li>
8993189911

89932-
<li><p>If running the module script throws an exception, then perform
89933-
<span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>, <var>specifier</var>,
89934-
<var>promiseCapability</var>, the thrown exception completion).</p></li>
89912+
<li><p>Otherwise, set <var>promise</var> to the result of <span data-x="run a module
89913+
script">running a module script</span> given <var>result</var> and true.</p></li>
8993589914

89936-
<li><p>Otherwise, perform
89937-
<span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>, <var>specifier</var>,
89938-
<var>promiseCapability</var>, <span>NormalCompletion</span>(undefined)).</p></li>
89915+
<li><p>Perform <span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>,
89916+
<var>specifier</var>, <var>promiseCapability</var>, <var>promise</var>).</p></li>
8993989917

8994089918
<li><p>Return undefined.</p></li>
8994189919
</ol>
@@ -122588,6 +122566,9 @@ INSERT INTERFACES HERE
122588122566
<dt id="refsJSINTL">[JSINTL]</dt>
122589122567
<dd><cite><a href="https://tc39.es/ecma402/">ECMAScript Internationalization API Specification</a></cite>. Ecma International.</dd>
122590122568

122569+
<dt id="refsJSTLA">[JSTLA]</dt>
122570+
<dd><cite><a href="https://tc39.es/proposal-top-level-await/">Top-Level Await</a></cite>. Ecma International.</dd>
122571+
122591122572
<dt id="refsJSON">[JSON]</dt>
122592122573
<dd><cite><a href="https://tools.ietf.org/html/rfc7159">The JavaScript Object Notation (JSON) Data Interchange Format</a></cite>, T. Bray. IETF.</dd>
122593122574

0 commit comments

Comments
 (0)