Opened 12 years ago

Closed 12 years ago

#2634 closed defect (wontfix)

dojo.event.browser.addListener accidentally uses global variable

Reported by: tim@… Owned by: anonymous
Priority: high Milestone:
Component: General Version: 0.3.0
Keywords: Cc:
Blocked By: Blocking:

Description

dojo.even.browser.addListener has the following:

		if(!dontFix){
			// build yet another closure around fp in order to inject fixEvent
			// around the resulting event
			var newfp = function(evt){
				if(!evt){ evt = window.event; }
				var ret = fp(dojo.event.browser.fixEvent(evt, this));
				if(capture){
					dojo.event.browser.stopEvent(evt);
				}
				return ret;
			}
		}else{
			newfp = fp;
		}

The else statement is accidentally setting a global variable newfp instead of a local one. It should instead be:

		var newfp;
		if(!dontFix){
			// build yet another closure around fp in order to inject fixEvent
			// around the resulting event
			newfp = function(evt){
				if(!evt){ evt = window.event; }
				var ret = fp(dojo.event.browser.fixEvent(evt, this));
				if(capture){
					dojo.event.browser.stopEvent(evt);
				}
				return ret;
			}
		}else{
			newfp = fp;
		}

It's unclear what consequences (if any) using a global here has, but it's better to not be surprised...

Change History (1)

comment:1 Changed 12 years ago by Adam Peller

Resolution: wontfix
Status: newclosed

this code was rewritten in 0.9

Note: See TracTickets for help on using tickets.