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

Rewrite the dispatch algorithm for click-like events #494

Merged
merged 11 commits into from Jan 31, 2024
25 changes: 16 additions & 9 deletions index.html
Expand Up @@ -811,15 +811,22 @@ <h4>Event coordinates</h4>
</section>
<section>
<h4>Event dispatch</h4>
<p>A <code>click</code>, <code>auxclick</code> or <code>contextmenu</code> event |e| MUST follow the dispatch process defined in [[UIEVENTS]] except when <em>all</em> of the following conditions are met:</p>
<ul>
<li>event |e| is fired in response to a user interaction event |t|,</li>
<li>event |t| is a <code>PointerEvent</code>,</li>
<li>event |t| was dispatched while the corresponding pointer was captured, and</li>
<li>the capturing target of event |t| is [=connected=] [[DOM]] at the moment event |e| is being dispatched.</li>
</ul>
<p>When these conditions are met, event |e| MUST be dispatched to the capturing target of event |t|, and event |e| MUST be dispatched after the dispatch of the {{GlobalEventHandlers/lostpointercapture}} event with the same <code>pointerId</code>.</p>
<div class="note">When |t| is a <code>PointerEvent</code>, its type depends on native platform convention: if |e| is a <code>contextmenu</code> event, |t| is either a {{GlobalEventHandlers/pointerdown}} or a {{GlobalEventHandlers/pointerup}} event; if |e| is a <code>click</code> or <code>auxclick</code> event, |t| is a {{GlobalEventHandlers/pointerup}} event.</div>
<p>A <code>click</code>, <code>auxclick</code> or <code>contextmenu</code> event |e| MUST follow the dispatch process defined in the [[UIEVENTS]] spec except for the overrides defined in the algorithm below:</p>
mustaqahmed marked this conversation as resolved.
Show resolved Hide resolved
<ol>
<li>Let |t| be the user interaction event that caused the firing of |e|.</li>
<div class="note">
mustaqahmed marked this conversation as resolved.
Show resolved Hide resolved
<p>Event |t| could be a non-<code>PointerEvent</code>; for example, it is a <code>KeyboardEvent</code> when a <code>click</code> event dispatch is caused by hitting the spacebar on a checkbox element.</p>
<p>When |t| is a <code>PointerEvent</code>, |t| is a {{GlobalEventHandlers/pointerup}} except for a <code>contextmenu</code> event where |t| is either a {{GlobalEventHandlers/pointerdown}} or a {{GlobalEventHandlers/pointerup}} event depending on native platform convention.</p>
</div>

<li>If |t| is not a <code>PointerEvent</code>, the dispatch of |e| MUST follow the [[UIEVENTS]] spec.</li>

<li>Otherwise, if |t| was dispatched while the corresponding pointer was captured, and the capturing target of event |t| is [=connected=] [[DOM]] at the moment event |e| is being dispatched, then the target of |e| MUST be the capturing target of event |t|, and |e| MUST be dispatched after the dispatch of the {{GlobalEventHandlers/lostpointercapture}} event with the same <code>pointerId</code>.</li>

<li>Otherwise, if |e| is a <code>contextmenu</code> event, the target of |e| MUST be the target of |t|.</li>

<li>Otherwise (|e| is a <code>click</code> or <code>auxclick</code> event): let |td| and |tu| be the targets of the corresponding <code>pointerdown</code> and <code>pointerup</code> events respectively. If both |td| and |tu| are [=connected=] [[DOM]] at the moment event |e| is being dispatched, the target of |e| MUST be the nearest common inclusive ancestor of |td| and |tu| in the DOM; otherwise, |e| is not dispatched at all.</li>
mustaqahmed marked this conversation as resolved.
Show resolved Hide resolved
</ol>
</section>
</section>
</section>
Expand Down