@@ -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 {
@@ -134,9 +134,6 @@ module.exports = function<T, P, I, TI, C>(
134
134
function commitInsertion ( finishedWork : Fiber ) : void {
135
135
// Recursively insert all host nodes into the parent.
136
136
const parent = getHostParent ( finishedWork ) ;
137
- if ( ! parent ) {
138
- return ;
139
- }
140
137
const before = getHostSibling ( finishedWork ) ;
141
138
// We only have the top Fiber that was inserted but we need recurse down its
142
139
// children to find all the terminal nodes.
@@ -208,9 +205,7 @@ module.exports = function<T, P, I, TI, C>(
208
205
commitNestedUnmounts ( node ) ;
209
206
// After all the children have unmounted, it is now safe to remove the
210
207
// node from the tree.
211
- if ( parent ) {
212
- removeChild ( parent , node . stateNode ) ;
213
- }
208
+ removeChild ( parent , node . stateNode ) ;
214
209
} else if ( node . tag === Portal ) {
215
210
// If this is a portal, then the parent is actually the portal itself.
216
211
// We need to keep track of which parent we're removing from.
0 commit comments