Fix traversal up when unmounting (#8404)
Previously you could get an alternate when following .return in unmountHostComponents and this could revisit a node twice.
Ben Alpert committed
Nov 23, 2016 at 16:07 UTC
c5b6601536c621ab8d68b97268b5c6af66b1d37d
1 file changed
+6
src/renderers/shared/fiber/ReactFiberCommitWork.js
+6
@@ -100,6 +100,7 @@ module.exports = function<T, P, I, TI, C>(
100
}
101
node = node.return;
102
}
103
+ node.sibling.return = node.return;
104
node = node.sibling;
105
while (node.tag !== HostComponent && node.tag !== HostText) {
106
// If it is not host node and, we might have a host node inside it.
@@ -112,6 +113,7 @@ module.exports = function<T, P, I, TI, C>(
113
if (!node.child) {
114
continue siblings;
115
} else {
116
+ node.child.return = node;
117
node = node.child;
118
}
119
}
@@ -169,6 +171,7 @@ module.exports = function<T, P, I, TI, C>(
171
commitUnmount(node);
172
if (node.child) {
173
// TODO: Coroutines need to visit the stateNode.
174
+ node.child.return = node;
175
node = node.child;
176
continue;
177
}
@@ -181,6 +184,7 @@ module.exports = function<T, P, I, TI, C>(
184
}
185
node = node.return;
186
}
187
+ node.sibling.return = node.return;
188
node = node.sibling;
189
}
190
}
@@ -201,6 +205,7 @@ module.exports = function<T, P, I, TI, C>(
205
commitUnmount(node);
206
if (node.child) {
207
// TODO: Coroutines need to visit the stateNode.
208
+ node.child.return = node;
209
node = node.child;
210
continue;
211
}
@@ -214,6 +219,7 @@ module.exports = function<T, P, I, TI, C>(
219
}
220
node = node.return;
221
}
222
+ node.sibling.return = node.return;
223
node = node.sibling;
224
}
225
}