#942 closed defect (fixed)
addEvent() fix for Opera
Reported by: | Owned by: | Christopher Lenz | |
---|---|---|---|
Priority: | normal | Milestone: | 0.8 |
Component: | general | Version: | devel |
Severity: | critical | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description (last modified by )
If you look at addEvent() (in trac.js), it reads:
if (element.addEventListener) { element.addEventListener(type, func, true); return true; } else if (element.attachEvent) { return element.attachEvent("on" + type, func); }
The first part is the DOM event model. It attaches the event to the capture phase due to the true argument.
The second part is for Internet Explorer. Its event model only has a bubble up phase.
So, as it is OK to use the bubble phase, I ask you to please change the DOM branch to also use the bubble phase (third parameter set to false).
The reason why this is better is a bug in Opera, which uses the DOM model. Attaching an event in capture mode to form elements does not make the browser trigger the event handler. Using bubble mode does so.
Now ticket.cs uses events to enable the "resolve as" and "reassign to" fields. With Opera, they do not get enabled, thus you can not reassign or resolve a ticket.
As this is a basic function of the ticket system, I consider this as "critical".
If you are cautious and do not want to change the parameter, please consider this patch:
--- /opt/trac-svn/trac/htdocs/trac.js 2004-11-16 23:29:56.000000000 +0100 +++ trac.js 2004-11-16 23:07:47.000000000 +0100 @@ -7,7 +20,10 @@ // A better way than for example hardcoding foo.onload function addEvent(element, type, func){ - if (element.addEventListener) { + if (window.opera && element.addEventListener) { + element.addEventListener(type, func, false); + return true; + else if (element.addEventListener) { element.addEventListener(type, func, true); return true; } else if (element.attachEvent) {
Attachments (0)
Change History (3)
comment:1 by , 20 years ago
comment:2 by , 20 years ago
Description: | modified (diff) |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Thanks for explaining the problem so nicely.
comment:3 by , 20 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I've changed the code to use the bubble phase in [1074] as you suggested, and it looks like it's working on all the browsers I have available for testing.
Damn, missed a } before the new "else if"