Page MenuHomePhabricator

Stratcom focus events are fired twice in Firefox and Opera
Closed, WontfixPublic

Description

Simple repro case:

JX.Stratcom.listen('focus', null, JX.log);

In all browsers (except Opera, see below) you'll get a single log with a single event id, but in Firefox it's fired twice.

They are also fired twice on anything *other than* window in Opera 10.6+ (haven't tried earlier) because of the Opera-specific hack in init.js:

if (window.opera) {
  document_events.push('focu​s', 'blur');
}

Opera seems to work fine without that hack, so maybe we can just remove it at this point?

(This was a bug we've had sitting around internally since December and I haven't tried to repro recently; I don't have time to look into it again so hoping someone else can give it some attention some day)

Event Timeline

Opera 25 on the mac fires once and Firefox 31 on the mac both fires twice. I tried to reproduce this issue by running

JX.Stratcom.listen('focus', null, JX.log);

in the console for each browser. Then I clicked into the browser window. The 'focus' event is then fired 1x and 2x for Opera and Firefox, respectively.

I think the issue for Firefox is from here http://www.quirksmode.org/dom/events/blurfocus.html

Firefox fires two focus and blur events when the events are registered in the capturing phase.

So I think the fix is to not register these events in the capturing phase for Firefox. Another web link offers thoughts on how to do this:

You, the web developer, can choose whether to register an event handler in the capturing or in the bubbling phase. This is done through the addEventListener() method explained on the Advanced models page. If its last argument is true the event handler is set for the capturing phase, if it is false the event handler is set for the bubbling phase.

from http://www.quirksmode.org/js/events_order.html

epriestley claimed this task.

Presuming no one cares anymore.

chad changed the visibility from "All Users" to "Public (No Login Required)".Nov 10 2015, 7:02 PM