Skip to content

Commit 8f96334

Browse files
committed
Make enterleave plugin not depend on window level listener
Preventively fixing this independently. Tested on both that branch (works) and master (works, except for the case of moving into Comp from `html`, in which case this will have a duplicate `enter`, since one extra mouseout is captured from `html`).
1 parent ea17506 commit 8f96334

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/browser/eventPlugins/EnterLeaveEventPlugin.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ var EnterLeaveEventPlugin = {
5656
* For almost every interaction we care about, there will be both a top-level
5757
* `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
5858
* we do not extract duplicate events. However, moving the mouse into the
59-
* browser from outside will not fire a `mouseout` event. In this case, we use
59+
* element from outside will not fire a `mouseout` event. In this case, we use
6060
* the `mouseover` top-level event.
6161
*
6262
* @param {string} topLevelType Record from `EventConstants`.
@@ -71,16 +71,22 @@ var EnterLeaveEventPlugin = {
7171
topLevelTarget,
7272
topLevelTargetID,
7373
nativeEvent) {
74-
if (topLevelType === topLevelTypes.topMouseOver &&
75-
(nativeEvent.relatedTarget || nativeEvent.fromElement)) {
76-
return null;
77-
}
7874
if (topLevelType !== topLevelTypes.topMouseOut &&
7975
topLevelType !== topLevelTypes.topMouseOver) {
80-
// Must not be a mouse in or mouse out - ignoring.
76+
// Unrelated event.
8177
return null;
8278
}
8379

80+
if (topLevelType === topLevelTypes.topMouseOver) {
81+
// `fromElement`/`toElement` are IE's equivalent of `relatedTarget`.
82+
var relatedTarget = nativeEvent.relatedTarget || nativeEvent.fromElement;
83+
// See docblock above. Ignore all `mouseover` unless they come from
84+
// outside of the top-level event listening container.
85+
if (relatedTarget && ReactMount.getFirstReactDOM(relatedTarget) != null) {
86+
return null;
87+
}
88+
}
89+
8490
var win;
8591
if (topLevelTarget.window === topLevelTarget) {
8692
// `topLevelTarget` is probably a window object.

0 commit comments

Comments
 (0)