Skip to content

Commit 9943801

Browse files
committed
Fix event path iteration
Instead of shoehorning all target handling into the bubbling iteration, this separates "capturing" iteration from "bubbling" iteration and the Event object's phase is set to target as appropriate in both. This also invokes the event listeners in a more natural order. Tests: web-platform-tests/wpt#13030 & web-platform-tests/wpt#13031. Fixes #685.
1 parent f296e1c commit 9943801

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

dom.bs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,22 +1385,28 @@ for discussion).
13851385
<var>clearTargetsStruct</var>'s <a for=Event/path>touch target list</a> is a <a for=/>node</a>
13861386
and its <a for=tree>root</a> is a <a for=/>shadow root</a>, and false otherwise.
13871387

1388-
<li><p>Set <var>event</var>'s {{Event/eventPhase}} attribute to {{Event/CAPTURING_PHASE}}.
1389-
13901388
<li><p>If <var>activationTarget</var> is non-null and <var>activationTarget</var> has
13911389
<a for=EventTarget>legacy-pre-activation behavior</a>, then run <var>activationTarget</var>'s
13921390
<a for=EventTarget>legacy-pre-activation behavior</a>.
13931391

13941392
<li>
1395-
<p>For each <var>struct</var> in <var>event</var>'s <a for=Event>path</a>, in reverse order:
1393+
<p><a for=list>For each</a> <var>struct</var> in <var>event</var>'s <a for=Event>path</a>, in
1394+
reverse order:
13961395

13971396
<ol>
1398-
<li><p>If <var>struct</var>'s <a for=Event/path>target</a> is null, then <a>invoke</a> with
1399-
<var>struct</var>, <var>event</var>, and <var>legacyOutputDidListenersThrowFlag</var> if given.
1397+
<li><p>If <var>struct</var>'s <a for=Event/path>target</a> is non-null, then set
1398+
<var>event</var>'s {{Event/eventPhase}} attribute to {{Event/AT_TARGET}}.
1399+
1400+
<li><p>Otherwise, set <var>event</var>'s {{Event/eventPhase}} attribute to
1401+
{{Event/CAPTURING_PHASE}}.
1402+
1403+
<li><p><a>Invoke</a> with <var>struct</var>, <var>event</var>, "<code>capturing</code>", and
1404+
<var>legacyOutputDidListenersThrowFlag</var> if given.
14001405
</ol>
14011406

14021407
<li>
1403-
<p>For each <var>struct</var> in <var>event</var>'s <a for=Event>path</a>, in order:
1408+
<p>If <var>event</var>'s {{Event/bubbles}} attribute is true, then <a for=list>for each</a>
1409+
<var>struct</var> in <var>event</var>'s <a for=Event>path</a>:
14041410

14051411
<ol>
14061412
<li><p>If <var>struct</var>'s <a for=Event/path>target</a> is non-null, then set
@@ -1409,10 +1415,8 @@ for discussion).
14091415
<li><p>Otherwise, set <var>event</var>'s {{Event/eventPhase}} attribute to
14101416
{{Event/BUBBLING_PHASE}}.
14111417

1412-
<li><p>If either <var>event</var>'s {{Event/eventPhase}} attribute is {{Event/BUBBLING_PHASE}}
1413-
and <var>event</var>'s {{Event/bubbles}} attribute is true or <var>event</var>'s
1414-
{{Event/eventPhase}} attribute is {{Event/AT_TARGET}}, then <a>invoke</a> with
1415-
<var>struct</var>, <var>event</var>, and <var>legacyOutputDidListenersThrowFlag</var> if given.
1418+
<li><p><a>Invoke</a> with <var>struct</var>, <var>event</var>, "<code>bubbling</code>", and
1419+
<var>legacyOutputDidListenersThrowFlag</var> if given.
14161420
</ol>
14171421
</ol>
14181422

@@ -1476,7 +1480,8 @@ for discussion).
14761480
</ol>
14771481

14781482
<p>To <dfn noexport id=concept-event-listener-invoke>invoke</dfn>, given a <var>struct</var>,
1479-
<var>event</var>, and an optional <var>legacyOutputDidListenersThrowFlag</var>, run these steps:
1483+
<var>event</var>, <var>phase</var>, and an optional <var>legacyOutputDidListenersThrowFlag</var>,
1484+
run these steps:
14801485

14811486
<ol>
14821487
<li><p>Set <var>event</var>'s <a for=Event>target</a> to the <a for=Event/path>target</a> of the
@@ -1502,7 +1507,7 @@ for discussion).
15021507
run. Note that removal still has an effect due to the <a for="event listener">removed</a> field.
15031508

15041509
<li><p>Let <var>found</var> be the result of running <a>inner invoke</a> with <var>event</var>,
1505-
<var>listeners</var>, and <var>legacyOutputDidListenersThrowFlag</var> if given.
1510+
<var>listeners</var>, <var>phase</var>, and <var>legacyOutputDidListenersThrowFlag</var> if given.
15061511

15071512
<li>
15081513
<p>If <var>found</var> is false and <var>event</var>'s {{Event/isTrusted}} attribute is true,
@@ -1526,15 +1531,15 @@ for discussion).
15261531
<tr><td>"<code>transitionend</code>"<td>"<code>webkitTransitionEnd</code>"
15271532
</table>
15281533

1529-
<li><p><a>Inner invoke</a> with <var>event</var>, <var>listeners</var>, and
1534+
<li><p><a>Inner invoke</a> with <var>event</var>, <var>listeners</var>, <var>phase</var>, and
15301535
<var>legacyOutputDidListenersThrowFlag</var> if given.
15311536

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

15361541
<p>To <dfn noexport id=concept-event-listener-inner-invoke>inner invoke</dfn>, given an
1537-
<var>event</var>, <var>listeners</var>, and an optional
1542+
<var>event</var>, <var>listeners</var>, <var>phase</var>, and an optional
15381543
<var>legacyOutputDidListenersThrowFlag</var>, run these steps:
15391544

15401545
<ol>
@@ -1550,13 +1555,11 @@ for discussion).
15501555

15511556
<li><p>Set <var>found</var> to true.
15521557

1553-
<li><p>If <var>event</var>'s {{Event/eventPhase}} attribute value is {{Event/CAPTURING_PHASE}}
1554-
and <var>listener</var>'s <a for="event listener">capture</a> is false, then
1555-
<a for=iteration>continue</a>.
1558+
<li><p>If <var>phase</var> is "<code>capturing</code>" and <var>listener</var>'s
1559+
<a for="event listener">capture</a> is false, then <a for=iteration>continue</a>.
15561560

1557-
<li><p>If <var>event</var>'s {{Event/eventPhase}} attribute value is {{Event/BUBBLING_PHASE}} and
1558-
<var>listener</var>'s <a for="event listener">capture</a> is true, then
1559-
<a for=iteration>continue</a>.
1561+
<li><p>If <var>phase</var> is "<code>bubbling</code>" and <var>listener</var>'s
1562+
<a for="event listener">capture</a> is true, then <a for=iteration>continue</a>.
15601563

15611564
<li><p>If <var>listener</var>'s <a for="event listener">once</a> is true, then
15621565
<a for=list>remove</a> <var>listener</var> from <var>event</var>'s {{Event/currentTarget}}
@@ -10051,6 +10054,7 @@ Mark Miller,
1005110054
Martijn van der Ven,
1005210055
Mats Palmgren,
1005310056
Mounir Lamouri,
10057+
Michael Stramel,
1005410058
Michael™ Smith,
1005510059
Mike Champion,
1005610060
Mike Taylor,

0 commit comments

Comments
 (0)