Skip to content

Commit 4062e28

Browse files
littledanMs2ger
authored andcommitted
[WIP] Top-level await integration
The purpose of this patch is to nail down how HTML would adjust to the needs of top-level await. The relevant change is, the module.Evaluate() method will return a Promise that resolves when the module is ready. Top-level await should reach stage 3 before this change lands. The PR where Evaluate returns a Promise is guybedford/proposal-top-level-await#1
1 parent a387c7b commit 4062e28

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

source

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3076,6 +3076,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
30763076
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-isconstructor">IsConstructor</dfn> abstract operation</li>
30773077
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-isdatadescriptor">IsDataDescriptor</dfn> abstract operation</li>
30783078
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-isdetachedbuffer">IsDetachedBuffer</dfn> abstract operation</li>
3079+
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-ispromise">IsPromise</dfn> abstract operation</li>
30793080
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-issharedarraybuffer">IsSharedArrayBuffer</dfn> abstract operation</li>
30803081
<li>The <dfn data-x="js-NewObjectEnvironment" data-x-href="https://tc39.es/ecma262/#sec-newobjectenvironment">NewObjectEnvironment</dfn> abstract operation</li>
30813082
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-normalcompletion">NormalCompletion</dfn> abstract operation</li>
@@ -3131,6 +3132,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
31313132
<p>User agents that support JavaScript must also implement the <cite>BigInt</cite> proposal. <ref
31323133
spec=JSBIGINT></p>
31333134

3135+
<p>User agents that support JavaScript must also implement the <cite>top-level await</cite>
3136+
proposal: <ref spec=JSTLA></p>
3137+
31343138
</dd>
31353139

31363140

@@ -89294,6 +89298,15 @@ interface <dfn>ApplicationCache</dfn> : <span>EventTarget</span> {
8929489298
</ol>
8929589299
</li>
8929689300

89301+
<li>
89302+
<p>If <span>IsPromise</span>(<var>evaluationStatus</var>) is true, then:</p>
89303+
89304+
<ol>
89305+
<li><p>Upon rejection of <var>evaluationStatus</var> with <var>reason</var>,
89306+
<span>report the exception</span> given by <var>reason</var> for <var>script</var>.</p></li>
89307+
</ol>
89308+
</li>
89309+
8929789310
<li><p><span>Clean up after running script</span> with <var>settings</var>.</p></li>
8929889311

8929989312
<li><p>Return <var>evaluationStatus</var>.</p></li>
@@ -90372,12 +90385,26 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
9037290385
</li>
9037390386

9037490387
<li><p><span data-x="run a module script">Run the module script</span> <var>result</var>, with
90375-
the rethrow errors boolean set to true.</p></li>
90388+
the rethrow errors boolean set to true, and let the result be <var>status</var>.</p></li>
9037690389

9037790390
<li><p>If running the module script throws an exception, then perform
9037890391
<span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>, <var>specifier</var>,
9037990392
<var>promiseCapability</var>, the thrown exception completion).</p></li>
9038090393

90394+
<li>
90395+
<p>If <span>IsPromise</span>(<var>status</var>) is true, then:</p>
90396+
90397+
<ol>
90398+
<li>Upon fulfillment of <var>status</var> with <var>value</var>, perform
90399+
<span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>, <var>specifier</var>,
90400+
<var>promiseCapability</var>, <var>value</var>).</li>
90401+
90402+
<li>Upon rejection of <var>status</var> with <var>reason</var>, perform
90403+
<span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>, <var>specifier</var>,
90404+
<var>promiseCapability</var>, Completion{ [[Type]]: throw, [[Value]]: <var>reason</var> }).</li>
90405+
</ol>
90406+
</li>
90407+
9038190408
<li><p>Otherwise, perform
9038290409
<span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>, <var>specifier</var>,
9038390410
<var>promiseCapability</var>, <span>NormalCompletion</span>(undefined)).</p></li>
@@ -123519,6 +123546,9 @@ INSERT INTERFACES HERE
123519123546
<dt id="refsJSINTL">[JSINTL]</dt>
123520123547
<dd><cite><a href="https://tc39.es/ecma402/">ECMAScript Internationalization API Specification</a></cite>. Ecma International.</dd>
123521123548

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

0 commit comments

Comments
 (0)