Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix event path iteration #686

Merged
merged 2 commits into from Mar 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
77 changes: 41 additions & 36 deletions dom.bs
Expand Up @@ -1306,43 +1306,47 @@ for discussion).
<li><p>Set <var>slot-in-closed-tree</var> to false.
</ol>

<li><p>Let <var>clearTargetsTuple</var> be the last tuple in <var>event</var>'s
<li><p>Let <var>clearTargetsStruct</var> be the last struct in <var>event</var>'s
<a for=Event>path</a> whose <a for=Event/path>target</a> is non-null.

<li><p>Let <var>clearTargets</var> be true if <var>clearTargetsTuple</var>'s
<a for=Event/path>target</a>, <var>clearTargetsTuple</var>'s <a for=Event/path>relatedTarget</a>,
or an {{EventTarget}} object in <var>clearTargetsTuple</var>'s
<a for=Event/path>touch target list</a> is a <a for=/>node</a> and its <a for=tree>root</a> is a
<a for=/>shadow root</a>, and false otherwise.

<li><p>Set <var>event</var>'s {{Event/eventPhase}} attribute to {{Event/CAPTURING_PHASE}}.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell "legacy-pre-activation behavior" cannot trigger side effects so setting this later is not observable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it looks like we fire change event on radio buttons & checkboxes so the event phase change is observable. Gecko follows the current spec and WebKit & Blink uses the new behavior.

https://gist.github.com/rniwa/6c502dca3e16d5816db7958ce7bab4d7

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, we should add that test to the test suite. None seems like a reasonable phase to me given that traversal hasn't started yet, WDYT @smaug----?

Copy link
Collaborator

@rniwa rniwa Sep 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that none seems more reasonable than capturing given the event dispatching hasn't even started yet.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From API user's point of view Gecko's behavior makes more sense, since for them the event dispatch clearly has started already once dispatchEvent is called.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree. Just because we're in dispatchEvent, doesn't mean eventPhase needs to be something other than "none".

<li><p>Let <var>clearTargets</var> be true if <var>clearTargetsStruct</var>'s
<a for=Event/path>target</a>, <var>clearTargetsStruct</var>'s
<a for=Event/path>relatedTarget</a>, or an {{EventTarget}} object in
<var>clearTargetsStruct</var>'s <a for=Event/path>touch target list</a> is a <a for=/>node</a>
and its <a for=tree>root</a> is a <a for=/>shadow root</a>, and false otherwise.

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

<li>
<p>For each <var>tuple</var> in <var>event</var>'s <a for=Event>path</a>, in reverse order:
<p><a for=list>For each</a> <var>struct</var> in <var>event</var>'s <a for=Event>path</a>, in
reverse order:

<ol>
<li><p>If <var>tuple</var>'s <a for=Event/path>target</a> is null, then <a>invoke</a> with
<var>tuple</var>, <var>event</var>, and <var>legacyOutputDidListenersThrowFlag</var> if given.
<li><p>If <var>struct</var>'s <a for=Event/path>target</a> is non-null, then set
<var>event</var>'s {{Event/eventPhase}} attribute to {{Event/AT_TARGET}}.

<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.
</ol>

<li>
<p>For each <var>tuple</var> in <var>event</var>'s <a for=Event>path</a>, in order:
<p>If <var>event</var>'s {{Event/bubbles}} attribute is true, then <a for=list>for each</a>
<var>struct</var> in <var>event</var>'s <a for=Event>path</a>:

<ol>
<li><p>If <var>tuple</var>'s <a for=Event/path>target</a> is non-null, then set
<li><p>If <var>struct</var>'s <a for=Event/path>target</a> is non-null, then set
<var>event</var>'s {{Event/eventPhase}} attribute to {{Event/AT_TARGET}}.

<li><p>Otherwise, set <var>event</var>'s {{Event/eventPhase}} attribute to
{{Event/BUBBLING_PHASE}}.

<li><p>If either <var>event</var>'s {{Event/eventPhase}} attribute is {{Event/BUBBLING_PHASE}}
and <var>event</var>'s {{Event/bubbles}} attribute is true or <var>event</var>'s
{{Event/eventPhase}} attribute is {{Event/AT_TARGET}}, then <a>invoke</a> with
<var>tuple</var>, <var>event</var>, and <var>legacyOutputDidListenersThrowFlag</var> if given.
<li><p><a>Invoke</a> with <var>struct</var>, <var>event</var>, "<code>bubbling</code>", and
<var>legacyOutputDidListenersThrowFlag</var> if given.
</ol>
</ol>

Expand Down Expand Up @@ -1405,23 +1409,24 @@ for discussion).
<a for=Event/path>slot-in-closed-tree</a> is <var>slot-in-closed-tree</var>.
</ol>

<p>To <dfn noexport id=concept-event-listener-invoke>invoke</dfn>, given a <var>tuple</var>,
<var>event</var>, and an optional <var>legacyOutputDidListenersThrowFlag</var>, run these steps:
<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:

<ol>
<li><p>Set <var>event</var>'s <a for=Event>target</a> to the <a for=Event/path>target</a> of the
last tuple in <var>event</var>'s <a for=Event>path</a>, that is either <var>tuple</var> or
preceding <var>tuple</var>, whose <a for=Event/path>target</a> is non-null.
last struct in <var>event</var>'s <a for=Event>path</a>, that is either <var>struct</var> or
preceding <var>struct</var>, whose <a for=Event/path>target</a> is non-null.

<li><p>Set <var>event</var>'s <a for=Event>relatedTarget</a> to <var>tuple</var>'s
<li><p>Set <var>event</var>'s <a for=Event>relatedTarget</a> to <var>struct</var>'s
<a for=Event/path>relatedTarget</a>.

<li><p>Set <var>event</var>'s <a for=Event>touch target list</a> to <var>tuple</var>'s
<li><p>Set <var>event</var>'s <a for=Event>touch target list</a> to <var>struct</var>'s
<a for=Event/path>touch target list</a>.

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

<li><p>Initialize <var>event</var>'s {{Event/currentTarget}} attribute to <var>tuple</var>'s
<li><p>Initialize <var>event</var>'s {{Event/currentTarget}} attribute to <var>struct</var>'s
<a for=Event/path>item</a>.

<li>
Expand All @@ -1432,7 +1437,7 @@ for discussion).
run. Note that removal still has an effect due to the <a for="event listener">removed</a> field.

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

<li>
<p>If <var>found</var> is false and <var>event</var>'s {{Event/isTrusted}} attribute is true,
Expand All @@ -1456,15 +1461,15 @@ for discussion).
<tr><td>"<code>transitionend</code>"<td>"<code>webkitTransitionEnd</code>"
</table>

<li><p><a>Inner invoke</a> with <var>event</var>, <var>listeners</var>, and
<li><p><a>Inner invoke</a> with <var>event</var>, <var>listeners</var>, <var>phase</var>, and
<var>legacyOutputDidListenersThrowFlag</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>, and an optional
<var>event</var>, <var>listeners</var>, <var>phase</var>, and an optional
<var>legacyOutputDidListenersThrowFlag</var>, run these steps:

<ol>
Expand All @@ -1480,13 +1485,11 @@ for discussion).

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

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

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

<li><p>If <var>listener</var>'s <a for="event listener">once</a> is true, then
<a for=list>remove</a> <var>listener</var> from <var>event</var>'s {{Event/currentTarget}}
Expand All @@ -1505,7 +1508,7 @@ for discussion).
<ol>
<li><p>Set <var>currentEvent</var> to <var>global</var>'s <a for=Window>current event</a>.

<li><p>If <var>tuple</var>'s <a for=Event/path>item-in-shadow-tree</a> is false, then set
<li><p>If <var>struct</var>'s <a for=Event/path>item-in-shadow-tree</a> is false, then set
<var>global</var>'s <a for=Window>current event</a> to <var>event</var>.
</ol>

Expand Down Expand Up @@ -5685,8 +5688,9 @@ or "<code>closed</code>").</p>

<p>A <a for=/>shadow root</a>'s <a>get the parent</a> algorithm, given an <var>event</var>, returns
null if <var>event</var>'s <a>composed flag</a> is unset and <a for=/>shadow root</a> is the
<a for=tree>root</a> of <var>event</var>'s <a for=Event>path</a>'s first tuple's <b>item</b>, and
<a for=/>shadow root</a>'s <a for=DocumentFragment>host</a> otherwise.
<a for=tree>root</a> of <var>event</var>'s <a for=Event>path</a>'s first struct's
<a for=Event/path>item</a>, and <a for=/>shadow root</a>'s <a for=DocumentFragment>host</a>
otherwise.

<p>The <dfn attribute for=ShadowRoot><code>mode</code></dfn> attribute's getter must return the
<a>context object</a>'s <a for=ShadowRoot>mode</a>.</p>
Expand Down Expand Up @@ -9982,6 +9986,7 @@ Mark Miller,
Martijn van der Ven,
Mats Palmgren,
Mounir Lamouri,
Michael Stramel,
Michael™ Smith,
Mike Champion,
Mike Taylor,
Expand Down