Edgewall Software
Modify

Ticket #942 (closed defect: fixed)

Opened 8 years ago

Last modified 6 years ago

addEvent() fix for Opera

Reported by: agr30@… Owned by: cmlenz
Priority: normal Milestone: 0.8
Component: general Version: devel
Severity: critical Keywords:
Cc:
Release Notes:
API Changes:

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) {

Attachments

Change History

comment:1 Changed 8 years ago by agr30@…

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

comment:2 Changed 8 years ago by cmlenz

  • Description modified (diff)
  • Owner changed from jonas to cmlenz
  • Status changed from new to assigned

Thanks for explaining the problem so nicely.

comment:3 Changed 8 years ago by cmlenz

  • Resolution set to fixed
  • Status changed from assigned to 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.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
to The owner will be changed from cmlenz. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.