Bug Tracker

Ticket #689 (closed bug: fixed)

Opened 8 years ago

Last modified 7 years ago

event.js .filter() leaks memory in IE

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

Description

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
			e.preventDefault();
			
			// 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

comment:1 Changed 8 years ago by joern

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in SVN.

Note: See TracTickets for help on using tickets.