Skip to content

Commit 89f25c8

Browse files
committed
Alternate method of jumping to the root of the render tree.
1 parent d1a2193 commit 89f25c8

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/renderers/dom/client/ReactEventListener.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,13 @@ PooledClass.addPoolingTo(
6262
);
6363

6464
function handleTopLevelImpl(bookKeeping) {
65-
// TODO: Re-enable event.path handling
66-
//
67-
// if (bookKeeping.nativeEvent.path && bookKeeping.nativeEvent.path.length > 1) {
68-
// // New browsers have a path attribute on native events
69-
// handleTopLevelWithPath(bookKeeping);
70-
// } else {
71-
// // Legacy browsers don't have a path attribute on native events
72-
// handleTopLevelWithoutPath(bookKeeping);
73-
// }
74-
75-
void handleTopLevelWithPath; // temporarily unused
76-
handleTopLevelWithoutPath(bookKeeping);
65+
if (bookKeeping.nativeEvent.path && bookKeeping.nativeEvent.path.length > 1) {
66+
// New browsers have a path attribute on native events
67+
handleTopLevelWithPath(bookKeeping);
68+
} else {
69+
// Legacy browsers don't have a path attribute on native events
70+
handleTopLevelWithoutPath(bookKeeping);
71+
}
7772
}
7873

7974
// Legacy browsers don't have a path attribute on native events
@@ -133,10 +128,9 @@ function handleTopLevelWithPath(bookKeeping) {
133128
);
134129

135130
// Jump to the root of this React render tree
136-
while (currentPathElementID !== newRootID) {
131+
var container = ReactMount.findReactContainerForID(newRootID);
132+
while (i + 1 < path.length && path[i + 1] !== container) {
137133
i++;
138-
currentPathElement = path[i];
139-
currentPathElementID = ReactMount.getID(currentPathElement);
140134
}
141135
}
142136
}

0 commit comments

Comments
 (0)