wpt icon indicating copy to clipboard operation
wpt copied to clipboard

Expectations in pointerevent_after_target_removed_from_slot.html

Open mustaqahmed opened this issue 1 month ago • 5 comments

The WPT in pointerevents/ is failing in all browsers, and it is not clear if the assertions in the test are spec-compliant.

Let's look at the first sub-test there for ease of discussion. Once we are confident what to expect there, hopefully other sub-tests will be trivial:


In the first sub-test "mouse events with remove-slot at pointerdown", we start with the following HTML where #slot is filled with #filler.

<div id="host">
  <template id="template" shadowrootmode="open">
    <style>
      div {
        width: 100px;
        height: 100px;
      }
    </style>
    <div id="parent">
      <slot id="slot">
        <div></div>
      </slot>
    </div>
  </template>

  <div id="filler"></div>
</div>

Then at pointerdown on #filler, #slot is deleted from the shadow-tree. At this point:

  • #filler becomes hidden while remaining connected to the light-DOM, and
  • the mouse pointer hovers on #parent (the shadow root).

Finally, at pointerup, the event is sent to #parent in all browsers.

Now let's look at two specific differences:

  1. Because of the first bullet above, I would expect pointerout and pointerleave events getting dispatched to #filler. Chrome and Safari dispatch them, Firefox does not. What does the spec want in this case?

  2. Because of the second bullet above, all browsers send a pointerover event to #parent. Chrome and Safari re-target this event to #host and Firefox does not. In a private email thread, @smaug---- mentioned this is somehow related to [1] above. Could you please elaborate?

mustaqahmed avatar Dec 01 '25 21:12 mustaqahmed

@mfreed7 Wondering what your thoughts are regrading the diffs in shadow-DOM event dispatch.

mustaqahmed avatar Dec 02 '25 15:12 mustaqahmed

Now let's look at two specific differences:

  1. Because of the first bullet above, I would expect pointerout and pointerleave events getting dispatched to #filler. Chrome and Safari dispatch them, Firefox does not. What does the spec want in this case?

I don't know what the spec wants. But this behavior (firing the boundary events) sounds reasonable to me, to avoid developer bugs where only one half of the boundary events are sent. But that's a very mild preference.

  1. Because of the second bullet above, all browsers send a pointerover event to #parent. Chrome and Safari re-target this event to #host and Firefox does not. In a private email thread, @smaug---- mentioned this is somehow related to [1] above. Could you please elaborate?

Sending a (retargeted) pointerover to #parent sounds reasonable to me.

mfreed7 avatar Dec 02 '25 15:12 mfreed7

@mustaqahmed relatedTarget is very important part here because it changes event propagation. Can you possible include also what is the .relatedTarget in different browsers in different cases. The issues Chrome has are, IIRC, related to it leaking shadow element via .relatedTarget to light DOM. We don't want that.

smaug---- avatar Dec 03 '25 21:12 smaug----

@mustaqahmed relatedTarget is very important part here because it changes event propagation. Can you possible include also what is the .relatedTarget in different browsers in different cases. The issues Chrome has are, IIRC, related to it leaking shadow element via .relatedTarget to light DOM. We don't want that.

Here is a repro matching the WPT but I added .relatedTarget in the log. The case I focused in the original post here is the default bullet in this repro, and it shows correct related targets in both Chrome and Safari (see the last two lines):

[Removing slot]
pointerout target=filler relTarget=host
pointerleave target=filler relTarget=host
pointerover target=parent relTarget=filler
pointerover target=host relTarget=filler

And Firefox emits this instead:

[Removing slot]
pointerover target=parent relTarget=parent

Few weeks ago you reported this Blink bug with leaked related targets, thanks! The WPT/repro here doesn't show the same leak for whatever reason (perhaps something to do with the depth of the <slot> in the shadow-DOM?), so I would defer that discussion for now.

mustaqahmed avatar Dec 04 '25 16:12 mustaqahmed

(I've transferred this issue to the WPT repo instead of interop, since this particular test is not in interop)

nt1m avatar Dec 09 '25 19:12 nt1m