Re: [whatwg] Should onblur be triggered for hidden nodes?

On Thu, Jan 8, 2015 at 3:38 AM, Rob Wu <rob@robwu.nl> wrote:

> 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?
>

I'd support doing this, having to fire blur events when nodes are removed
has been a frequent source of security bugs and complexity in WebKit/blink.

This does mean you can't do certain fancy focus behaviors, but given that
most browsers don't do it anyway we should get rid of it.


>
> Kind regards,
>  Rob
>  https://robwu.nl
>
> [1]
>
> https://html.spec.whatwg.org/multipage/interaction.html#focus-fixup-rule-one
>

Received on Saturday, 24 January 2015 01:50:49 UTC