Skip to main content

Bug Tracker

Side navigation

#689 closed bug (fixed)

Opened December 22, 2006 03:12PM UTC

Closed December 24, 2006 01:16AM UTC

Last modified June 20, 2007 02:13AM UTC

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 );
Attachments (0)
Change History (1)

Changed December 24, 2006 01:16AM UTC by joern comment:1

resolution: → fixed
status: newclosed

Fixed in SVN.