Bug Tracker


Ticket #689 (closed bug: fixed)

Opened 7 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:


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

comment:1 Changed 7 years ago by joern

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

Fixed in SVN.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.


Add a comment

Modify Ticket

as closed

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.