Skip to content

Commit 9b3a066

Browse files
committed
Editorial: name event path items and clarify target selection
An event's path was defined as a list of unnamed structs, which made the invoke algorithm's target selection hard to follow: "the last struct ... that is either struct or preceding struct, whose shadow-adjusted target is non-null" reads as picking the outermost struct rather than searching backward from the current one. Fixes #707.
1 parent eb0dfd5 commit 9b3a066

1 file changed

Lines changed: 71 additions & 59 deletions

File tree

dom.bs

Lines changed: 71 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -492,15 +492,20 @@ empty list.
492492
{{TouchEvent}} interface and related interfaces. [[TOUCH-EVENTS]]
493493

494494
<p>An <a>event</a> has an associated <dfn export for=Event>path</dfn>. A <a for=Event>path</a> is a
495-
<a for=/>list</a> of <a for=/>structs</a>. Each <a for=/>struct</a> consists of an
496-
<dfn for=Event/path>invocation target</dfn> (an {{EventTarget}} object), an
497-
<dfn for=Event/path>invocation-target-in-shadow-tree</dfn> (a boolean), a
498-
<dfn for=Event/path>shadow-adjusted target</dfn> (a <a>potential event target</a>), a
499-
<dfn id=event-path-relatedtarget for=Event/path>relatedTarget</dfn> (a
500-
<a>potential event target</a>), a <dfn for=Event/path>touch target list</dfn> (a <a for=/>list</a>
501-
of <a>potential event targets</a>), a <dfn for=Event/path>root-of-closed-tree</dfn> (a boolean), and
502-
a <dfn for=Event/path>slot-in-closed-tree</dfn> (a boolean). A <a for=Event>path</a> is initially
503-
the empty list.
495+
<a for=/>list</a> of <a>event path items</a>. An <dfn>event path item</dfn> is a <a for=/>struct</a>
496+
consisting of an <dfn id=event-path-invocation-target for="event path item">invocation target</dfn>
497+
(an {{EventTarget}} object), an
498+
<dfn id=event-path-invocation-target-in-shadow-tree for="event path item">invocation-target-in-shadow-tree</dfn>
499+
(a boolean), a
500+
<dfn id=event-path-shadow-adjusted-target for="event path item">shadow-adjusted target</dfn> (a
501+
<a>potential event target</a>), a
502+
<dfn id=event-path-relatedtarget for="event path item">relatedTarget</dfn> (a
503+
<a>potential event target</a>), a
504+
<dfn id=event-path-touch-target-list for="event path item">touch target list</dfn> (a
505+
<a for=/>list</a> of <a>potential event targets</a>), a
506+
<dfn id=event-path-root-of-closed-tree for="event path item">root-of-closed-tree</dfn> (a boolean),
507+
and a <dfn id=event-path-slot-in-closed-tree for="event path item">slot-in-closed-tree</dfn> (a
508+
boolean). A <a for=Event>path</a> is initially the empty list.
504509

505510
<dl class=domintro>
506511
<dt><code><var>event</var> = new <a constructor lt="Event()">Event</a>(<var>type</var> [, <var>eventInitDict</var>])</code>
@@ -525,7 +530,7 @@ the empty list.
525530
invoked.
526531

527532
<dt><code><var>event</var> . {{Event/composedPath()}}</code>
528-
<dd>Returns the <a for=Event/path>invocation target</a> objects of <var>event</var>'s
533+
<dd>Returns the <a for="event path item">invocation target</a> objects of <var>event</var>'s
529534
<a for=Event>path</a> (objects on which listeners will be invoked), except for any
530535
<a for=/>nodes</a> in <a for=/>shadow trees</a> of which the <a for=/>shadow root</a>'s
531536
<a for=ShadowRoot>mode</a> is "<code>closed</code>" that are not reachable from <var>event</var>'s
@@ -621,15 +626,15 @@ was initialized to. When an <a>event</a> is created the attribute must be initia
621626
<p>While <var>index</var> is greater than or equal to 0:
622627

623628
<ol>
624-
<li><p>If <var>path</var>[<var>index</var>]'s <a for=Event/path>root-of-closed-tree</a> is true,
625-
then increase <var>currentTargetHiddenSubtreeLevel</var> by 1.
629+
<li><p>If <var>path</var>[<var>index</var>]'s <a for="event path item">root-of-closed-tree</a> is
630+
true, then increase <var>currentTargetHiddenSubtreeLevel</var> by 1.
626631

627-
<li><p>If <var>path</var>[<var>index</var>]'s <a for=Event/path>invocation target</a> is
632+
<li><p>If <var>path</var>[<var>index</var>]'s <a for="event path item">invocation target</a> is
628633
<var>currentTarget</var>, then set <var>currentTargetIndex</var> to <var>index</var> and
629634
<a for=iteration>break</a>.
630635

631-
<li><p>If <var>path</var>[<var>index</var>]'s <a for=Event/path>slot-in-closed-tree</a> is true,
632-
then decrease <var>currentTargetHiddenSubtreeLevel</var> by 1.
636+
<li><p>If <var>path</var>[<var>index</var>]'s <a for="event path item">slot-in-closed-tree</a> is
637+
true, then decrease <var>currentTargetHiddenSubtreeLevel</var> by 1.
633638

634639
<li><p>Decrease <var>index</var> by 1.
635640
</ol>
@@ -643,15 +648,16 @@ was initialized to. When an <a>event</a> is created the attribute must be initia
643648
<p>While <var>index</var> is greater than or equal to 0:
644649

645650
<ol>
646-
<li><p>If <var>path</var>[<var>index</var>]'s <a for=Event/path>root-of-closed-tree</a> is true,
647-
then increase <var>currentHiddenLevel</var> by 1.
651+
<li><p>If <var>path</var>[<var>index</var>]'s <a for="event path item">root-of-closed-tree</a> is
652+
true, then increase <var>currentHiddenLevel</var> by 1.
648653

649654
<li><p>If <var>currentHiddenLevel</var> is less than or equal to <var>maxHiddenLevel</var>, then
650655
<a for=list>prepend</a> <var>path</var>[<var>index</var>]'s
651-
<a for=Event/path>invocation target</a> to <var>composedPath</var>.
656+
<a for="event path item">invocation target</a> to <var>composedPath</var>.
652657

653658
<li>
654-
<p>If <var>path</var>[<var>index</var>]'s <a for=Event/path>slot-in-closed-tree</a> is true:
659+
<p>If <var>path</var>[<var>index</var>]'s <a for="event path item">slot-in-closed-tree</a> is
660+
true:
655661

656662
<ol>
657663
<li><p>Decrease <var>currentHiddenLevel</var> by 1.
@@ -672,15 +678,16 @@ was initialized to. When an <a>event</a> is created the attribute must be initia
672678
<p>While <var>index</var> is less than <var>path</var>'s <a for=list>size</a>:
673679

674680
<ol>
675-
<li><p>If <var>path</var>[<var>index</var>]'s <a for=Event/path>slot-in-closed-tree</a> is true,
676-
then increase <var>currentHiddenLevel</var> by 1.
681+
<li><p>If <var>path</var>[<var>index</var>]'s <a for="event path item">slot-in-closed-tree</a> is
682+
true, then increase <var>currentHiddenLevel</var> by 1.
677683

678684
<li><p>If <var>currentHiddenLevel</var> is less than or equal to <var>maxHiddenLevel</var>, then
679685
<a for=list>append</a> <var>path</var>[<var>index</var>]'s
680-
<a for=Event/path>invocation target</a> to <var>composedPath</var>.
686+
<a for="event path item">invocation target</a> to <var>composedPath</var>.
681687

682688
<li>
683-
<p>If <var>path</var>[<var>index</var>]'s <a for=Event/path>root-of-closed-tree</a> is true:
689+
<p>If <var>path</var>[<var>index</var>]'s <a for="event path item">root-of-closed-tree</a> is
690+
true:
684691

685692
<ol>
686693
<li><p>Decrease <var>currentHiddenLevel</var> by 1.
@@ -1486,38 +1493,38 @@ property of the event being dispatched.
14861493
<li><p>Set <var>slot-in-closed-tree</var> to false.
14871494
</ol>
14881495

1489-
<li><p>Let <var>clearTargetsStruct</var> be the last struct in <var>event</var>'s
1490-
<a for=Event>path</a> whose <a for=Event/path>shadow-adjusted target</a> is non-null.
1496+
<li><p>Let <var>clearTargetsItem</var> be the last <a>event path item</a> in <var>event</var>'s
1497+
<a for=Event>path</a> whose <a for="event path item">shadow-adjusted target</a> is non-null.
14911498

1492-
<li><p>If <var>clearTargetsStruct</var>'s <a for=Event/path>shadow-adjusted target</a>,
1493-
<var>clearTargetsStruct</var>'s <a for=Event/path>relatedTarget</a>, or an {{EventTarget}} object
1494-
in <var>clearTargetsStruct</var>'s <a for=Event/path>touch target list</a> is a <a for=/>node</a>
1499+
<li><p>If <var>clearTargetsItem</var>'s <a for="event path item">shadow-adjusted target</a>,
1500+
<var>clearTargetsItem</var>'s <a for="event path item">relatedTarget</a>, or an {{EventTarget}} object
1501+
in <var>clearTargetsItem</var>'s <a for="event path item">touch target list</a> is a <a for=/>node</a>
14951502
whose <a for=tree>root</a> is a <a for=/>shadow root</a>: set <var>clearTargets</var> to true.
14961503

14971504
<li><p>If <var>activationTarget</var> is non-null and <var>activationTarget</var> has
14981505
<a for=EventTarget>legacy-pre-activation behavior</a>, then run <var>activationTarget</var>'s
14991506
<a for=EventTarget>legacy-pre-activation behavior</a>.
15001507

15011508
<li>
1502-
<p><a for=list>For each</a> <var>struct</var> of <var>event</var>'s <a for=Event>path</a>, in
1509+
<p><a for=list>For each</a> <var>item</var> of <var>event</var>'s <a for=Event>path</a>, in
15031510
reverse order:
15041511

15051512
<ol>
1506-
<li><p>If <var>struct</var>'s <a for=Event/path>shadow-adjusted target</a> is non-null, then
1513+
<li><p>If <var>item</var>'s <a for="event path item">shadow-adjusted target</a> is non-null, then
15071514
set <var>event</var>'s {{Event/eventPhase}} attribute to {{Event/AT_TARGET}}.
15081515

15091516
<li><p>Otherwise, set <var>event</var>'s {{Event/eventPhase}} attribute to
15101517
{{Event/CAPTURING_PHASE}}.
15111518

1512-
<li><p><a>Invoke</a> with <var>struct</var>, <var>event</var>, "<code>capturing</code>", and
1519+
<li><p><a>Invoke</a> with <var>item</var>, <var>event</var>, "<code>capturing</code>", and
15131520
<var>legacyOutputDidListenersThrowFlag</var> if given.
15141521
</ol>
15151522

15161523
<li>
1517-
<p><a for=list>For each</a> <var>struct</var> of <var>event</var>'s <a for=Event>path</a>:
1524+
<p><a for=list>For each</a> <var>item</var> of <var>event</var>'s <a for=Event>path</a>:
15181525

15191526
<ol>
1520-
<li><p>If <var>struct</var>'s <a for=Event/path>shadow-adjusted target</a> is non-null, then
1527+
<li><p>If <var>item</var>'s <a for="event path item">shadow-adjusted target</a> is non-null, then
15211528
set <var>event</var>'s {{Event/eventPhase}} attribute to {{Event/AT_TARGET}}.
15221529

15231530
<li>
@@ -1530,7 +1537,7 @@ property of the event being dispatched.
15301537
<li><p>Set <var>event</var>'s {{Event/eventPhase}} attribute to {{Event/BUBBLING_PHASE}}.
15311538
</ol>
15321539

1533-
<li><p><a>Invoke</a> with <var>struct</var>, <var>event</var>, "<code>bubbling</code>", and
1540+
<li><p><a>Invoke</a> with <var>item</var>, <var>event</var>, "<code>bubbling</code>", and
15341541
<var>legacyOutputDidListenersThrowFlag</var> if given.
15351542
</ol>
15361543
</ol>
@@ -1588,38 +1595,43 @@ steps:
15881595
<li><p>If <var>invocationTarget</var> is a <a for=/>shadow root</a> whose <a for=ShadowRoot>mode</a>
15891596
is "<code>closed</code>", then set <var>root-of-closed-tree</var> to true.
15901597

1591-
<li><p><a for=list>Append</a> a new <a for=/>struct</a> to <var>event</var>'s <a for=Event>path</a>
1592-
whose <a for=Event/path>invocation target</a> is <var>invocationTarget</var>,
1593-
<a for=Event/path>invocation-target-in-shadow-tree</a> is <var>invocationTargetInShadowTree</var>,
1594-
<a for=Event/path>shadow-adjusted target</a> is <var>shadowAdjustedTarget</var>,
1595-
<a for=Event/path>relatedTarget</a> is <var>relatedTarget</var>,
1596-
<a for=Event/path>touch target list</a> is <var>touchTargets</var>,
1597-
<a for=Event/path>root-of-closed-tree</a> is <var>root-of-closed-tree</var>, and
1598-
<a for=Event/path>slot-in-closed-tree</a> is <var>slot-in-closed-tree</var>.
1598+
<li><p><a for=list>Append</a> a new <a>event path item</a> to <var>event</var>'s
1599+
<a for=Event>path</a> whose
1600+
<a for="event path item">invocation target</a> is <var>invocationTarget</var>,
1601+
<a for="event path item">invocation-target-in-shadow-tree</a> is <var>invocationTargetInShadowTree</var>,
1602+
<a for="event path item">shadow-adjusted target</a> is <var>shadowAdjustedTarget</var>,
1603+
<a for="event path item">relatedTarget</a> is <var>relatedTarget</var>,
1604+
<a for="event path item">touch target list</a> is <var>touchTargets</var>,
1605+
<a for="event path item">root-of-closed-tree</a> is <var>root-of-closed-tree</var>, and
1606+
<a for="event path item">slot-in-closed-tree</a> is <var>slot-in-closed-tree</var>.
15991607
</ol>
16001608
</div>
16011609

16021610
<div algorithm>
1603-
<p>To <dfn noexport id=concept-event-listener-invoke>invoke</dfn>, given a <var>struct</var>,
1604-
<var>event</var>, <var>phase</var>, and an optional <var>legacyOutputDidListenersThrowFlag</var>,
1605-
run these steps:
1611+
<p>To <dfn noexport id=concept-event-listener-invoke>invoke</dfn>, given an <a>event path item</a>
1612+
<var>pathItem</var>, an <a>event</a> <var>event</var>, a string <var>phase</var>, and an optional
1613+
<var>legacyOutputDidListenersThrowFlag</var>:
16061614

16071615
<ol>
1608-
<li><p>Set <var>event</var>'s <a for=Event>target</a> to the
1609-
<a for=Event/path>shadow-adjusted target</a> of the last struct in <var>event</var>'s
1610-
<a for=Event>path</a>, that is either <var>struct</var> or preceding <var>struct</var>, whose
1611-
<a for=Event/path>shadow-adjusted target</a> is non-null.
1616+
<li><p>Let <var>targetItem</var> be <var>pathItem</var>.
16121617

1613-
<li><p>Set <var>event</var>'s <a for=Event>relatedTarget</a> to <var>struct</var>'s
1614-
<a for=Event/path>relatedTarget</a>.
1618+
<li><p>While <var>targetItem</var>'s <a for="event path item">shadow-adjusted target</a> is null: set
1619+
<var>targetItem</var> to the <a>event path item</a> preceding <var>targetItem</var> in
1620+
<var>event</var>'s <a for=Event>path</a>.
16151621

1616-
<li><p>Set <var>event</var>'s <a for=Event>touch target list</a> to <var>struct</var>'s
1617-
<a for=Event/path>touch target list</a>.
1622+
<li><p>Set <var>event</var>'s <a for=Event>target</a> to <var>targetItem</var>'s
1623+
<a for="event path item">shadow-adjusted target</a>.
1624+
1625+
<li><p>Set <var>event</var>'s <a for=Event>relatedTarget</a> to <var>pathItem</var>'s
1626+
<a for="event path item">relatedTarget</a>.
1627+
1628+
<li><p>Set <var>event</var>'s <a for=Event>touch target list</a> to <var>pathItem</var>'s
1629+
<a for="event path item">touch target list</a>.
16181630

16191631
<li><p>If <var>event</var>'s <a>stop propagation flag</a> is set, then return.
16201632

1621-
<li><p>Initialize <var>event</var>'s {{Event/currentTarget}} attribute to <var>struct</var>'s
1622-
<a for=Event/path>invocation target</a>.
1633+
<li><p>Initialize <var>event</var>'s {{Event/currentTarget}} attribute to <var>pathItem</var>'s
1634+
<a for="event path item">invocation target</a>.
16231635

16241636
<li>
16251637
<p>Let <var>listeners</var> be a <a for=list>clone</a> of <var>event</var>'s
@@ -1628,8 +1640,8 @@ run these steps:
16281640
<p class=note>This avoids <a>event listeners</a> added after this point from being
16291641
run. Note that removal still has an effect due to the <a for="event listener">removed</a> field.
16301642

1631-
<li><p>Let <var>invocationTargetInShadowTree</var> be <var>struct</var>'s
1632-
<a for=Event/path>invocation-target-in-shadow-tree</a>.
1643+
<li><p>Let <var>invocationTargetInShadowTree</var> be <var>pathItem</var>'s
1644+
<a for="event path item">invocation-target-in-shadow-tree</a>.
16331645

16341646
<li><p>Let <var>found</var> be the result of running <a>inner invoke</a> with <var>event</var>,
16351647
<var>listeners</var>, <var>phase</var>, <var>invocationTargetInShadowTree</var>, and
@@ -6598,8 +6610,8 @@ is null.
65986610

65996611
<p>A <a for=/>shadow root</a>'s <a>get the parent</a> algorithm, given an <var>event</var>, returns
66006612
null if <var>event</var>'s <a>composed flag</a> is unset and <a for=/>shadow root</a> is the
6601-
<a for=tree>root</a> of <var>event</var>'s <a for=Event>path</a>'s first struct's
6602-
<a for=Event/path>invocation target</a>; otherwise <a for=/>shadow root</a>'s
6613+
<a for=tree>root</a> of <var>event</var>'s <a for=Event>path</a>'s first <a>event path item</a>'s
6614+
<a for="event path item">invocation target</a>; otherwise <a for=/>shadow root</a>'s
66036615
<a for=DocumentFragment>host</a>.
66046616

66056617
<hr>

0 commit comments

Comments
 (0)