Ticket #942 (closed defect: fixed)
addEvent() fix for Opera
| Reported by: | agr30@… | Owned by: | cmlenz |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.8 |
| Component: | general | Version: | devel |
| Severity: | critical | Keywords: | |
| Cc: |
Description (last modified by cmlenz) (diff)
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) {


