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

2.4k views Asked by At

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?

1

There are 1 answers

0
T.J. Crowder On BEST ANSWER

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. :-)