Bug Tracker

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#689 closed bug (fixed)

event.js .filter() leaks memory in IE

Reported by: Dave Owned by:
Priority: minor Milestone:
Component: event Version:
Keywords: Cc:
Blocked by: Blocking:


The .toggle method remembers the current state by attaching one of the functions to a .last property of the DOM element. This will cause a memory leak in IE. Using a non-object (number) with a closure gets rid of the leak. Also, using a.constructor==Function will fail if the function is contained in an iframe, so I switched to typeof.

	toggle: function(a,b) {
		var args = arguments;
		// If two functions are passed in, we're toggling on a click
		return typeof(a) == "function" && typeof(b) == "function" ? this.bind("click",function(e){
			// Figure out which function to execute
			this.lastToggle = this.lastToggle==0? 1 : 0;
			// Make sure that clicks stop
			// and execute the function
			return args[this.lastToggle].apply( this, [e] ) || false;
		}) :
		// Otherwise, execute the old toggle function
		this._toggle.apply( this, arguments );

Change History (1)

comment:1 Changed 16 years ago by joern

Resolution: fixed
Status: newclosed

Fixed in SVN.

Note: See TracTickets for help on using tickets.