#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: |
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 ); },
Note: See
TracTickets for help on using
tickets.
Fixed in SVN.