Why event.bubbles is false for "focusin" and "focusout"?
Asked Answered
A

1

10

Couple of minutes ago, I answered the question:
What is the difference between focusin/focusout vs focus/blur in jQuery?

The answer was:

Short answer: focusin    bubbles, focus does not.
        focusout bubbles, blur   does not.

I tested it, it's true, but I encountered a weird thing while trying to set up a DEMO:

$('#test').on('focusin focusout focus blur change', function(e) {
    console.log(e.type + 'event bubles? : ' + e.bubbles);
});​

focusin and focusout give me e.bubbles == false

Is it a bug of jQuery or am I missing the obvious here?

Ansell answered 14/5, 2012 at 13:40 Comment(1)
False/false in Chrome 18 (in case you want some browser notes...)Undersea
L
4

Sounds like a bug in jQuery. Did you test this on a browser that supports focusin and focusout natively? (E.g., IE?) Because if not, you're testing the flag for jQuery's emulated support.

I've crossed out the "Sounds like a bug" bit above because jQuery doesn't claim to normalize the bubbles property in the documentation. So since it doesn't guarantee it, it doesn't have to support it on emulated events. (Note that if I run your demo on IE7, I get undefined because IE7 doesn't support the DOM3 Events bubbles property.) Still an issue, but perhaps not a bug. :-)


Update:

Response on the jQuery ticket:

The documentation doesn't claim to normalize the event.bubbles property. You can look for it in event.originalEvent but that will be whatever the platform provided, unnormalized.

So my guess above was correct. It's not a bug, because they don't claim to normalize that. :-)

Lance answered 14/5, 2012 at 13:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.