The spec of the focusing algorithm [1] is not explicit about removed/hidden
nodes. It seems to allow the change / blur / focusout events to be
dispatched when an element becomes hidden or is removed from the document.

All non-WebKit-based users agents (Trident, Gecko, Presto) do NOT follow
this behavior. I.e. upon node removal, the change/blur/focusout events are
not dispatched.
WebKit and Blink deviate from the other UAs, they do trigger these events (
crbug.com/439484).

This discrepancy became even more significant when Blink started to match
other UA's behaviors and focus anchor elements upon click (
crbug.com/388666#c10). Now, out of all browsers that focus an <a> element
upon click, Blink is the only one that triggers the blur event when a node
is hidden/removed. This difference has caused some broken websites and bug
reports.

There are two options here:
- Dispatch change / blur / focusout when an element is unfocused,
regardless of whether the element is still in the document.
- Ignore hidden / removed elements in the focusing algorithm; i.e. do not
dispatch these events.

I'm inclined to vote for the second option, because the majority of the
distinct user agents already follow this behavior.
What do you think?

Kind regards,
 Rob
 https://robwu.nl

[1]
https://html.spec.whatwg.org/multipage/interaction.html#focus-fixup-rule-one

Reply via email to