I have a problem with mouseenter/mouseleave unexpected behavior in Firefox. The thing I need to do is:
- Move the node to another place in DOM after mouse enter has been registered on it
 - Then move it back to original place after mouse leave has been registerd on it
 
The problem is that after inserting the node into another place, mouseenter fires like crazy and mouseleave doesn't fire at all.
Here's a pen illustrating that. You should inspect console output to see how many times mouseenter is fired. It might seem nonsensical in the pen, but in my app it isn't. I'm adding a zoom to the image on hover. One of it's ancestor's has overflow: hidden (which I cannot fight with CSS) and hides the enlarged portion of the image. So after the image is zoomed I need to move it into some other place in DOM (while making sure that it stays in the same place on the screen), then move it back in place when zoom is over (mouse leaves the image).
Question
Can someone explain to me what happens here? And how to fight it to achieve the regular mouseenter and mouseleave behavior (fired only once).
                        
First: Your variables
outer1andouter2are the same.Second, if you are changing the element of node it will trigger the
mouseleavebecause the cursor is no longer on top of the element..I think this is what you are trying to achieve:
As you can see I only listen to the
mouseenterevent because themouseleavewill always be triggered after you append the element. I added a flag:movedto figure out where the div is.