Skip to content

Commit

Permalink
Add support for AsyncContext in dispatching Events
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed Dec 12, 2023
1 parent ca756e0 commit e7ea06b
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1270,8 +1270,9 @@ property of the event being dispatched.
<h3 id=dispatching-events>Dispatching events</h3>

<p>To <dfn export id=concept-event-dispatch>dispatch</dfn> an <var>event</var> to a
<var>target</var>, with an optional <var>legacy target override flag</var> and an optional
<var>legacyOutputDidListenersThrowFlag</var>, run these steps:
<var>target</var>, with an optional <var>legacy target override flag</var>, an optional
<var>legacyOutputDidListenersThrowFlag</var>, and an optional
<var>useCallerAsyncContextFlag</var>, run these steps:

<ol>
<li><p>Set <var>event</var>'s <a>dispatch flag</a>.
Expand Down Expand Up @@ -1408,8 +1409,9 @@ property of the event being dispatched.
<li><p>Otherwise, set <var>event</var>'s {{Event/eventPhase}} attribute to
{{Event/CAPTURING_PHASE}}.

<li><p><a>Invoke</a> with <var>struct</var>, <var>event</var>, "<code>capturing</code>", and
<var>legacyOutputDidListenersThrowFlag</var> if given.
<li><p><a>Invoke</a> with <var>struct</var>, <var>event</var>, "<code>capturing</code>",
<var>legacyOutputDidListenersThrowFlag</var> if given, and
<var>useCallerAsyncContextFlag</var> if given.
</ol>

<li>
Expand All @@ -1429,8 +1431,9 @@ property of the event being dispatched.
<li><p>Set <var>event</var>'s {{Event/eventPhase}} attribute to {{Event/BUBBLING_PHASE}}.
</ol>

<li><p><a>Invoke</a> with <var>struct</var>, <var>event</var>, "<code>bubbling</code>", and
<var>legacyOutputDidListenersThrowFlag</var> if given.
<li><p><a>Invoke</a> with <var>struct</var>, <var>event</var>, "<code>bubbling</code>",
<var>legacyOutputDidListenersThrowFlag</var> if given, and
<var>useCallerAsyncContextFlag</var> if given.
</ol>
</ol>

Expand Down Expand Up @@ -1496,8 +1499,9 @@ steps:</p>
</ol>

<p>To <dfn noexport id=concept-event-listener-invoke>invoke</dfn>, given a <var>struct</var>,
<var>event</var>, <var>phase</var>, and an optional <var>legacyOutputDidListenersThrowFlag</var>,
run these steps:
<var>event</var>, <var>phase</var>, an optional <var>legacyOutputDidListenersThrowFlag</var>,
an optional <var>legacyOutputDidListenersThrowFlag</var> if given, and an optional
<var>useCallerAsyncContextFlag</var>, run these steps:

<ol>
<li><p>Set <var>event</var>'s <a for=Event>target</a> to the
Expand Down Expand Up @@ -1527,8 +1531,9 @@ run these steps:
<a for=Event/path>invocation-target-in-shadow-tree</a>.

<li><p>Let <var>found</var> be the result of running <a>inner invoke</a> with <var>event</var>,
<var>listeners</var>, <var>phase</var>, <var>invocationTargetInShadowTree</var>, and
<var>legacyOutputDidListenersThrowFlag</var> if given.
<var>listeners</var>, <var>phase</var>, <var>invocationTargetInShadowTree</var>,
<var>legacyOutputDidListenersThrowFlag</var> if given, and <var>useCallerAsyncContextFlag</var> if
given.

<li>
<p>If <var>found</var> is false and <var>event</var>'s {{Event/isTrusted}} attribute is true,
Expand All @@ -1553,20 +1558,24 @@ run these steps:
</table>

<li><p><a>Inner invoke</a> with <var>event</var>, <var>listeners</var>, <var>phase</var>,
<var>invocationTargetInShadowTree</var>, and <var>legacyOutputDidListenersThrowFlag</var>
if given.
<var>invocationTargetInShadowTree</var>, <var>legacyOutputDidListenersThrowFlag</var> if given,
and <var>useCallerAsyncContextFlag</var> if given.

<li><p>Set <var>event</var>'s {{Event/type}} attribute value to <var>originalEventType</var>.
</ol>
</ol>

<p>To <dfn noexport id=concept-event-listener-inner-invoke>inner invoke</dfn>, given an
<var>event</var>, <var>listeners</var>, <var>phase</var>, <var>invocationTargetInShadowTree</var>,
and an optional <var>legacyOutputDidListenersThrowFlag</var>, run these steps:
and an optional <var>legacyOutputDidListenersThrowFlag</var>, and an optional
<var>useCallerAsyncContextFlag</var>, run these steps:

<ol>
<li><p>Let <var>found</var> be false.

<li><p>Let <var>useCreationTimeAsyncContext</var> be false if
<var>useCallerAsyncContextFlag</var> is passed and true otherwise.

<li>
<p><a for=list>For each</a> <var>listener</var> in <var>listeners</var>, whose
<a for="event listener">removed</a> is false:
Expand Down Expand Up @@ -1609,8 +1618,9 @@ and an optional <var>legacyOutputDidListenersThrowFlag</var>, run these steps:

<li>
<p><a>Call a user object's operation</a> with <var>listener</var>'s
<a for="event listener">callback</a>, "<code>handleEvent</code>", « <var>event</var> », and
<var>event</var>'s {{Event/currentTarget}} attribute value. If this throws an exception, then:
<a for="event listener">callback</a>, "<code>handleEvent</code>", « <var>event</var> »,
<var>event</var>'s {{Event/currentTarget}} attribute value, and
<var>useCreationTimeAsyncContext</var>. If this throws an exception, then:

<ol>
<li><p><a>Report the exception</a>.
Expand Down Expand Up @@ -1639,7 +1649,8 @@ and an optional <var>legacyOutputDidListenersThrowFlag</var>, run these steps:

<p>To <dfn export id=concept-event-fire>fire an event</dfn> named <var>e</var> at <var>target</var>,
optionally using an <var>eventConstructor</var>, with a description of how IDL attributes are to be
initialized, and a <var>legacy target override flag</var>, run these steps:
initialized, a <var>legacy target override flag</var>, and an optional
<var>useCallerAsyncContextFlag</var> run these steps:

<ol>
<li><p>If <var>eventConstructor</var> is not given, then let <var>eventConstructor</var> be
Expand All @@ -1657,7 +1668,8 @@ initialized, and a <var>legacy target override flag</var>, run these steps:
<p class=note>This also allows for the {{Event/isTrusted}} attribute to be set to false.

<li><p>Return the result of <a>dispatching</a> <var>event</var> at <var>target</var>, with
<var>legacy target override flag</var> set if set.
<var>legacy target override flag</var> set if set, and <var>useCallerAsyncContextFlag</var> set if
set.
</ol>

<p class=note>Fire in the context of DOM is short for
Expand Down

0 comments on commit e7ea06b

Please sign in to comment.