mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
committed by
Dan Abramov
parent
9288591e90
commit
8b496ba28f
+1
-8
@@ -27,10 +27,7 @@ export function getClosestInstanceFromNode(node) {
|
||||
return node[internalInstanceKey];
|
||||
}
|
||||
|
||||
// Walk up the tree until we find an ancestor whose instance we have cached.
|
||||
let parents = [];
|
||||
while (!node[internalInstanceKey]) {
|
||||
parents.push(node);
|
||||
if (node.parentNode) {
|
||||
node = node.parentNode;
|
||||
} else {
|
||||
@@ -40,17 +37,13 @@ export function getClosestInstanceFromNode(node) {
|
||||
}
|
||||
}
|
||||
|
||||
let closest;
|
||||
let inst = node[internalInstanceKey];
|
||||
if (inst.tag === HostComponent || inst.tag === HostText) {
|
||||
// In Fiber, this will always be the deepest root.
|
||||
return inst;
|
||||
}
|
||||
for (; node && (inst = node[internalInstanceKey]); node = parents.pop()) {
|
||||
closest = inst;
|
||||
}
|
||||
|
||||
return closest;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user