You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We believe there is a bug in the way can.debounce works:
function(fn,time,context){vartimeout;returnfunction(){varargs=arguments;context=context||this;// buggy line, can be fixed by using var myContext = context || thisclearTimeout(timeout);timeout=setTimeout(function(){fn.apply(context,args);},time);};}
The context is saved in the returned function's closure so that all future calls to the debounce will get the saved context.
We discovered this bug when using can.debounce to create a event handler function for a can.Component. Once the can.Component is destroyed and reinitialized, the old (destroyed) can.Component's context is used in the can.debounce function.
I can create a JSFiddle if required but this is pretty easy to reproduce.
Thanks,
Colin Zhu
The text was updated successfully, but these errors were encountered:
Hello,
We believe there is a bug in the way can.debounce works:
The
context
is saved in the returned function's closure so that all future calls to the debounce will get the saved context.We discovered this bug when using can.debounce to create a event handler function for a can.Component. Once the can.Component is destroyed and reinitialized, the old (destroyed) can.Component's context is used in the can.debounce function.
I can create a JSFiddle if required but this is pretty easy to reproduce.
Thanks,
Colin Zhu
The text was updated successfully, but these errors were encountered: