当 DOM 节点在 DOM 中移动时,如何阻止 Firefox 触发 mouseleave?

Dav*_*ker 5 javascript svg d3.js

我通过使路径成为其父级中的最后一个子级来响应 SVG 路径元素上的 mouseenter 事件。这就是它出现在其他元素之上的原因(不幸的是,SVG 内容上没有 z-index)。问题是在 Firefox 上这会导致 mouseleave 事件触发。这在 Chrome 上运行良好。

// on mousenter
node.parentNode.appendChild(node)
// this triggers a mouseleave .. if i don't move the node it works
Run Code Online (Sandbox Code Playgroud)

有谁知道解决方法或其他方法?

Rob*_*son 0

在appendChild之前删除处理程序并在之后恢复它。