Edgewall Software
Modify

Opened 20 years ago

Closed 20 years ago

Last modified 18 years ago

#942 closed defect (fixed)

addEvent() fix for Opera

Reported by: agr30@… 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 Christopher Lenz)

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 agr30@…, 20 years ago

Damn, missed a } before the new "else if"

comment:2 by Christopher Lenz, 20 years ago

Description: modified (diff)
Owner: changed from Jonas Borgström to Christopher Lenz
Status: newassigned

Thanks for explaining the problem so nicely.

comment:3 by Christopher Lenz, 20 years ago

Resolution: fixed
Status: assignedclosed

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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christopher Lenz.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christopher Lenz to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.