Skip to content

Commit

Permalink
Editorial: Update uses of WebIDL "invoke a callback function"
Browse files Browse the repository at this point in the history
It's now required for non-promise-returning uses to specify how
exceptions are handled. Specifying the argument list is also made more
consistent, using the shorthand syntax for lists where appropriate.

Part of whatwg/webidl#1425.
  • Loading branch information
jeremyroman committed Aug 2, 2024
1 parent 0068b12 commit ac1fcff
Showing 1 changed file with 23 additions and 41 deletions.
64 changes: 23 additions & 41 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -64478,7 +64478,7 @@ callback <dfn callback>BlobCallback</dfn> = undefined (<span>Blob</span>? blob);
<ref>FILEAPI</ref></p></li>

<li><p><span data-x="es-invoking-callback-functions">Invoke</span> <var>callback</var> with
« <var>result</var> ».</p></li>
« <var>result</var> » and "<code data-x="">report</code>".</p></li>
</ol>
</li>
</ol>
Expand Down Expand Up @@ -111511,27 +111511,25 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
<dt>If <var>special error event handling</var> is true</dt>

<dd>
<p><span data-x="es-invoking-callback-functions">Invoke</span> <var>callback</var> with five
arguments, the first one having the value of <var>event</var>'s <code
data-x="dom-ErrorEvent-message">message</code> attribute, the second having the value of
<var>event</var>'s <code data-x="dom-ErrorEvent-filename">filename</code> attribute, the third
having the value of <var>event</var>'s <code data-x="dom-ErrorEvent-lineno">lineno</code>
attribute, the fourth having the value of <var>event</var>'s <code
data-x="dom-ErrorEvent-colno">colno</code> attribute, the fifth having the value of
<var>event</var>'s <code data-x="dom-ErrorEvent-error">error</code> attribute, and with the <i
data-x="dfn-callback-this-value">callback this value</i> set to <var>event</var>'s <code
<p><span data-x="es-invoking-callback-functions">Invoke</span> <var>callback</var> with «
<var>event</var>'s <code data-x="dom-ErrorEvent-message">message</code>, <var>event</var>'s
<code data-x="dom-ErrorEvent-filename">filename</code>, <var>event</var>'s <code
data-x="dom-ErrorEvent-lineno">lineno</code>, <var>event</var>'s <code
data-x="dom-ErrorEvent-colno">colno</code>, <var>event</var>'s <code
data-x="dom-ErrorEvent-error">error</code> », "<code data-x="">rethrow</code>", and with the
<i data-x="dfn-callback-this-value">callback this value</i> set to <var>event</var>'s <code
data-x="dom-Event-currentTarget">currentTarget</code>. Let <var>return value</var> be the
callback's return value. <ref>WEBIDL</ref></p>
</dd>

<dt>Otherwise</dt>

<dd>
<p><span data-x="es-invoking-callback-functions">Invoke</span> <var>callback</var>
with one argument, the value of which is the <code>Event</code> object <var>event</var>,
with the <i data-x="dfn-callback-this-value">callback this value</i> set to <var>event</var>'s
<code data-x="dom-Event-currentTarget">currentTarget</code>. Let <var>return value</var> be
the callback's return value. <ref>WEBIDL</ref></p>
<p><span data-x="es-invoking-callback-functions">Invoke</span> <var>callback</var> with «
<var>event</var> », "<code data-x="">rethrow</code>", and with the <i
data-x="dfn-callback-this-value">callback this value</i> set to <var>event</var>'s <code
data-x="dom-Event-currentTarget">currentTarget</code>. Let <var>return value</var> be the
callback's return value. <ref>WEBIDL</ref></p>
</dd>
</dl>

Expand Down Expand Up @@ -113702,17 +113700,10 @@ enum <dfn enum>DOMParserSupportedType</dfn> {
<li><p><span>Record timing info for timer handler</span> given <var>handler</var>, <var>global</var>'s
<span>relevant settings object</span>, and <var>repeat</var>.</p></li>

<li>
<p>If <var>handler</var> is a <code data-x="idl-Function">Function</code>, then <span
data-x="es-invoking-callback-functions">invoke</span> <var>handler</var> given
<var>arguments</var> with the <span data-x="dfn-callback-this-value">callback this
value</span> set to <var>thisArg</var>. If this throws an exception, catch it, and <span
data-x="report an exception">report</span> it for <var>handler</var>'s corresponding
JavaScript object's <span>associated realm</span>'s <span
data-x="concept-realm-global">global object</span>.</p>

<p class="note">This global object not necessarily the same as <var>global</var>, if
<var>handler</var> comes from another <span>realm</span>.</p>
<li><p>If <var>handler</var> is a <code data-x="idl-Function">Function</code>, then <span
data-x="es-invoking-callback-functions">invoke</span> <var>handler</var> given
<var>arguments</var> and "<code data-x="">report</code>", and with the <span
data-x="dfn-callback-this-value">callback this value</span> set to <var>thisArg</var>.</p>
</li>

<li>
Expand Down Expand Up @@ -113958,12 +113949,7 @@ scheduleWork(); // queues a task to do lots of work</code></pre>
<p w-nodev>The <dfn method for="WindowOrWorkerGlobalScope"><code
data-x="dom-queueMicrotask">queueMicrotask(<var>callback</var>)</code></dfn> method must
<span>queue a microtask</span> to <span data-x="es-invoking-callback-functions">invoke</span>
<var>callback</var>, and if <var>callback</var> throws an exception, <span data-x="report an
exception">report</span> it for <var>callback</var>'s corresponding JavaScript object's
<span>associated realm</span>'s <span data-x="concept-realm-global">global object</span>.</p>

<p w-nodev class="note">This global object not necessarily the same as <span>this</span>, if
<var>callback</var> comes from another <span>realm</span>.</p>
<var>callback</var> with « » and "<code data-x="">report</code>.</p>

<p>The <code data-x="dom-queueMicrotask">queueMicrotask()</code> method allows authors to schedule
a callback on the <span>microtask queue</span>. This allows their code to run once the
Expand Down Expand Up @@ -116100,13 +116086,8 @@ interface mixin <dfn interface>AnimationFrameProvider</dfn> {
<li><p><span data-x="map remove">Remove</span>
<var>callbacks</var>[<var>handle</var>].</p></li>

<li><p><span data-x="es-invoking-callback-functions">Invoke</span> <var>callback</var>, passing
<var>now</var> as the only argument, and if an exception is thrown,
<span data-x="report an exception">report</span> it for <var>callback</var>'s
corresponding JavaScript object's <span>associated realm</span>'s
<span data-x="concept-realm-global">global object</span>.</p>
<p class="note">This global object not necessarily the same as <var>this</var>, if
<var>callback</var> comes from another <span>realm</span>.</p></li>
<li><p><span data-x="es-invoking-callback-functions">Invoke</span> <var>callback</var> with «
<var>now</var> » and "<code data-x="">report</code>".</p></li>
</ol>
</li>
</ol>
Expand Down Expand Up @@ -120403,8 +120384,9 @@ window.fakeWorklet1.addModule("script.mjs");</code></pre>
data-x="idl-Function">Function</code> instance.</p></li>

<li><p>Return the result of <span data-x="es-invoking-callback-functions">invoking</span>
<var>callback</var> with the arguments « true » and with <var>classInstance</var> as the <span
data-x="dfn-callback-this-value">callback this value</span>.</p></li>
<var>callback</var> with the arguments « true » and "<code data-x="">rethrow</code>, and with
<var>classInstance</var> as the <span data-x="dfn-callback-this-value">callback this
value</span>.</p></li>
</ol>

<p class="note">Another, perhaps better, specification architecture would be to extract the "<code
Expand Down

0 comments on commit ac1fcff

Please sign in to comment.