Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#14728 closed feature (fixed)

support stopImmediatePropagation()

Reported by: bill Owned by: Kris Zyp
Priority: blocker Milestone: 1.8
Component: Events Version: 1.7.1
Keywords: Cc: cjolif
Blocked By: Blocking:


Newer browsers' event objects have a stopImmediatePropagation() method. It would be nice if you could normalize the events from older browsers to have this too.

Unfortunately, even IE8 is missing this method, so dropping support for IE6-7 wouldn't help.

I think the implementation (for browsers that don't support this natively) would be fairly simple, just calling stopPropagation() and then setting a flag on the event object that subsequent handlers would check.

My personal use case for this feature is to help with widget event propagation. Consider a button widget with a template like:

<span>click me</span>

And some JS code to support a disabled attribute, for example:

postCreate: function(){
      on(this.domNode, "click", lang.hitch(this, function(evt){
             if(this.disabled){ evt.stopImmediatePropagation(); }

And now consider that an app does:

on(dojo.byId("mybutton"), "click", function(){

I need the second event handler to not fire, even though it's on the same DOMNode.

Attachments (1)

stopImmediatePropagation.txt (740 bytes) - added by Martin Repta 10 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 10 years ago by Kris Zyp

Would we need to normalize Webkit and FF (will be supporting versions that don't have stopImmediatePropagation), or just old IE?

comment:2 Changed 10 years ago by bill

I wondered about that too. It's not supported in FF3.6 or FF8, which we are supporting according to our release notes for 1.8. FF3.6 is or will be EOL before we ship 1.8 but for some reason #14570 talks about supporting FF3.6 until dojo 1.9.

Personally I'd prefer not to waste time on EOL'd browsers so we should debate it if the work is significant.

Last edited 10 years ago by bill (previous) (diff)

comment:3 Changed 10 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

In [28041]:

Add support for stopImmediatePropagation, fixes #14728
Add support augmenting event objects in IE, fixes #14729 !strict

comment:4 Changed 10 years ago by bill

Milestone: tbd1.8

comment:5 Changed 10 years ago by Patrick Ruzand

Since this patch, the dojox.geo.openlayers.tests.test_widget.html does not work anymore. The reason is that OpenLayers? defines a global Event object as a litteral object in case window.Event is not defined. (see Therefore, the line:

has.add("event-stopimmediatepropogation", window.Event && !!window.Event.prototype.stopImmediatePropagation);

raises an error because Event.prototype is not defined in this case.

Honestly I am not sure who is the culprit, but maybe the code should double-check that we are in a case where window.Event has a prototype ?

comment:6 Changed 10 years ago by Patrick Ruzand

Resolution: fixed
Status: closedreopened

Changed 10 years ago by Martin Repta

comment:7 Changed 10 years ago by Martin Repta

I am also using OpenLayers?. I have added simple quick fix.

comment:8 Changed 10 years ago by cjolif

Cc: cjolif added

comment:9 Changed 10 years ago by Patrick Ruzand

Priority: undecidedblocker

The dojox/geo/openlayers tests are broken under IE8/7 because of this. see comment#5

comment:10 Changed 10 years ago by Patrick Ruzand

Resolution: fixed
Status: reopenedclosed

In [28962]:

fix stopImmediatePropagation detection, fixes #14728 !strict

comment:11 Changed 10 years ago by bill

In [29194]:

spelling, refs #14728 !strict

Note: See TracTickets for help on using tickets.