@@ -66,7 +66,7 @@ module.exports = function<T, P, I, TI, C>(
66
66
}
67
67
}
68
68
69
- function getHostParent ( fiber : Fiber ) : null | I | C {
69
+ function getHostParent ( fiber : Fiber ) : I | C {
70
70
let parent = fiber . return ;
71
71
while ( parent ) {
72
72
switch ( parent . tag ) {
@@ -79,7 +79,7 @@ module.exports = function<T, P, I, TI, C>(
79
79
}
80
80
parent = parent . return ;
81
81
}
82
- return null ;
82
+ throw new Error ( 'Expected to find a host parent.' ) ;
83
83
}
84
84
85
85
function isHostParent ( fiber : Fiber ) : boolean {
@@ -132,9 +132,6 @@ module.exports = function<T, P, I, TI, C>(
132
132
function commitInsertion ( finishedWork : Fiber ) : void {
133
133
// Recursively insert all host nodes into the parent.
134
134
const parent = getHostParent ( finishedWork ) ;
135
- if ( ! parent ) {
136
- return ;
137
- }
138
135
const before = getHostSibling ( finishedWork ) ;
139
136
// We only have the top Fiber that was inserted but we need recurse down its
140
137
// children to find all the terminal nodes.
@@ -204,9 +201,7 @@ module.exports = function<T, P, I, TI, C>(
204
201
commitNestedUnmounts ( node ) ;
205
202
// After all the children have unmounted, it is now safe to remove the
206
203
// node from the tree.
207
- if ( parent ) {
208
- removeChild ( parent , node . stateNode ) ;
209
- }
204
+ removeChild ( parent , node . stateNode ) ;
210
205
} else if ( node . tag === Portal ) {
211
206
// If this is a portal, then the parent is actually the portal itself.
212
207
// We need to keep track of which parent we're removing from.
0 commit comments