I had some event code which failed in Opera and I have stripped it down to this small testcase.
Basically the problem is that the event handler doesn’t run in Opera if the third parameter of addEventListener is not set. The value in the testcase increments in both Firefox and Chrome when the “useCapture not set”-button is clicked, but not in Opera.
This (old) article indicates that Opera is different than webkit & gecko browsers:
http://my.opera.com/hallvors/blog/2006/10/12/2006-10-12-event-capture-explained. I’m not sure what to make out of it though. MDN says useCapture should default to false.
is the default true in Opera, is the parameter simply not optional, or what am I missing? What is the correct behaviour?
If in doubt, refer to the spec. The original and still current spec is W3C’s DOM Level 2 Events. Looking at the ECMASCript binding page, it looks as though the
useCaptureparameter is required, since there is no mention of it being optional.DOM Level 3 Events explicitly mentions
useCaptureas being optional, although I don’t think this draft spec has ever reached widespread adoption in browsers.The relevant MDN page also has a note on this:
Bottom line: it’s safest to always pass in all three parameters, and Opera is well within its rights to insist on it.