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
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
After an alternating series of on/off calls for mouseenter or mouseleave, the event listener starts being invoked more often than expected.
Say you have a reference to a jqLite-wrapped element, $element, and you want to invoke some function when the mouse enters that element:
$element.on('mouseenter',someFn);
Now, someFn is invoked once every time the mouse enters the DOM element wrapped by $element, as expected.
Now detach that listener:
$element.off('mouseenter',someFn);
No, someFn is no longer invoked when the mouse enters that DOM element, again as expected.
Now, reattach the listener:
$element.on('mouseenter',someFn);
Observe: Now someFn is invoked twice whenever the mouse enters the specified DOM element, which is not expected.
More generally, after n calls to on and n - 1 calls to off, the event listener starts getting invoked n times per mouse entry, instead of once as expected.
This is true for mouseenter and mouseleave but does not appear to be the case for other events.