Opened 7 years ago

Closed 6 years ago

#18250 closed defect (duplicate)

[patch] on.selector event registration method prevents default behaviour in IE8

Reported by: cbikar Owned by: dylan
Priority: undecided Milestone: 1.11
Component: Events Version: 1.10.0
Keywords: Cc:
Blocked By: Blocking:


This bug is critical as it affects all pages using dojo/on in IE8.

After registering an EventListener? on an anchor element using the <selector>:<type> syntax and declaring a <selector> that doesn't exist, the event propagation is cancelled in IE8. The problem occurs in the on.selector function. The return statement is

return eventTarget &&, event);

If eventTarget cannot be found, because the selector does not match any element in the DOM, eventTarget is false. So the function returns false as well and therefore prevents the default event action to be executed in IE8, e.g., for an anchor the href attribute would have no effect.

Please find a simple test case attached.

Attachments (1)

dojotest.html (765 bytes) - added by cbikar 7 years ago.

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by cbikar

Attachment: dojotest.html added

comment:1 Changed 7 years ago by chris2m

I can confirm this is a severe issue in Internet Explorer 8, as it prevents the default behavior of events. All you need to do to make your page unusable in IE8 is to have something like on(node, ".classNameDoesNotExist:click", function(){}); on the page.

Why it happens

From dojo 1.9.3 to dojo 1.10.0 the method on.selector inside the module "dojo/on" was refactored. Part of its functionality was put into a method called on.matches. Where before, the method would return undefined, it now returns false.

How to fix

To fix this bug, we need to ensure that on.selector never returns false as this would prevent the event's default behavior in some browsers.

// standard event delegation
return on(target, eventType, function(event){

    // call select to see if we match
    var eventTarget = select(;
    // if it matches we call the listener

   if(eventTarget === false){

   return eventTarget &&, event);

comment:2 Changed 6 years ago by dylan

Milestone: tbd1.11
Owner: set to dylan
Status: newassigned

comment:3 Changed 6 years ago by dylan

Summary: on.selector event registration method prevents default behaviour in IE8[patch] on.selector event registration method prevents default behaviour in IE8

comment:4 Changed 6 years ago by dylan

Resolution: duplicate
Status: assignedclosed
Note: See TracTickets for help on using tickets.