-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
What is the issue with the HTML Standard?
If I'm reading https://html.spec.whatwg.org/multipage/dnd.html#drag-and-drop-processing-model correctly, in the ongoing processing step 3.1, we can only ever set current target for which one of these is true: (a) non-DOM (b) canceled dragenter
(c) is a text input (d) is the body element. Afterwards, it is only possible for dragleave
to fire on a target element. However, in all three browsers I tested, dragleave
fires on all DOM elements, regardless if they've elected to become a target by canceling dragenter
. Here's the minimum code:
<p id="p1" draggable="true">This element is draggable.</p>
<p id="foo">Foo</p>
<p id="bar">Bar</p>
foo.ondragleave = (e) => console.log("dragleave", e.target);
bar.ondragleave = (e) => console.log("dragleave", e.target);
I see the events firing. It seems that for all browsers, the only requirement for drop
to happen is for dragover
to be canceled (which is also not supposed to fire on these elements!). I'm not sure if this is Mac-specific behavior.
Furthermore I'm slightly confused about these two statements:
If the immediate user selection is the body element
- Leave the current target element unchanged.
Otherwise
- Fire a DND event named dragenter at the body element, if there is one, or at the Document object, if not. Then, set the current target element to the body element, regardless of whether that event was canceled or not.
To my naïve eyes, if I'm moving directly from a drop target to the body
, I would expect current target to become body
anyway, but this algorithm seems to say that the target should remain that drop target.