@@ -89,8 +89,11 @@ export function diff(
89
89
90
90
outer: if ( typeof newType == 'function' ) {
91
91
try {
92
- let c , isNew , oldProps , oldState , snapshot , clearProcessingException ;
93
- let newProps = newVNode . props ;
92
+ let c ,
93
+ oldProps ,
94
+ oldState ,
95
+ snapshot ,
96
+ newProps = newVNode . props ;
94
97
const isClassComponent =
95
98
'prototype' in newType && newType . prototype . render ;
96
99
@@ -109,7 +112,6 @@ export function diff(
109
112
c = newVNode . _component = oldVNode . _component ;
110
113
if ( c . _bits & COMPONENT_PENDING_ERROR ) {
111
114
c . _bits |= COMPONENT_PROCESSING_EXCEPTION ;
112
- clearProcessingException = true ;
113
115
}
114
116
} else {
115
117
// Instantiate the new component
@@ -132,7 +134,6 @@ export function diff(
132
134
if ( ! c . state ) c . state = { } ;
133
135
c . context = componentContext ;
134
136
c . _globalContext = globalContext ;
135
- isNew = true ;
136
137
c . _bits |= COMPONENT_DIRTY ;
137
138
c . _renderCallbacks = [ ] ;
138
139
c . _stateCallbacks = [ ] ;
@@ -159,7 +160,7 @@ export function diff(
159
160
c . _vnode = newVNode ;
160
161
161
162
// Invoke pre-render lifecycle methods
162
- if ( isNew ) {
163
+ if ( ! oldVNode . _component ) {
163
164
if (
164
165
isClassComponent &&
165
166
newType . getDerivedStateFromProps == NULL &&
@@ -269,21 +270,24 @@ export function diff(
269
270
globalContext = assign ( { } , globalContext , c . getChildContext ( ) ) ;
270
271
}
271
272
272
- if ( isClassComponent && ! isNew && c . getSnapshotBeforeUpdate != NULL ) {
273
+ if (
274
+ isClassComponent &&
275
+ oldVNode . _component &&
276
+ c . getSnapshotBeforeUpdate != NULL
277
+ ) {
273
278
snapshot = c . getSnapshotBeforeUpdate ( oldProps , oldState ) ;
274
279
}
275
280
276
281
let isTopLevelFragment =
277
282
tmp != NULL && tmp . type === Fragment && tmp . key == NULL ;
278
- let renderResult = tmp ;
279
283
280
284
if ( isTopLevelFragment ) {
281
- renderResult = cloneNode ( tmp . props . children ) ;
285
+ tmp = cloneNode ( tmp . props . children ) ;
282
286
}
283
287
284
288
oldDom = diffChildren (
285
289
parentDom ,
286
- isArray ( renderResult ) ? renderResult : [ renderResult ] ,
290
+ isArray ( tmp ) ? tmp : [ tmp ] ,
287
291
newVNode ,
288
292
oldVNode ,
289
293
globalContext ,
@@ -303,7 +307,7 @@ export function diff(
303
307
commitQueue . push ( c ) ;
304
308
}
305
309
306
- if ( clearProcessingException ) {
310
+ if ( c . _bits & COMPONENT_PENDING_ERROR ) {
307
311
c . _bits &= ~ ( COMPONENT_PROCESSING_EXCEPTION | COMPONENT_PENDING_ERROR ) ;
308
312
}
309
313
} catch ( e ) {
@@ -664,13 +668,11 @@ function diffElementNodes(
664
668
export function applyRef ( ref , value , vnode ) {
665
669
try {
666
670
if ( typeof ref == 'function' ) {
667
- let hasRefUnmount = typeof ref . _unmount == 'function' ;
668
- if ( hasRefUnmount ) {
669
- // @ts -ignore TS doesn't like moving narrowing checks into variables
671
+ if ( typeof ref . _unmount == 'function' ) {
670
672
ref . _unmount ( ) ;
671
673
}
672
674
673
- if ( ! hasRefUnmount || value != NULL ) {
675
+ if ( typeof ref . _unmount != 'function' || value != NULL ) {
674
676
// Store the cleanup function on the function
675
677
// instance object itself to avoid shape
676
678
// transitioning vnode
@@ -693,10 +695,8 @@ export function unmount(vnode, parentVNode, skipRemove) {
693
695
let r ;
694
696
if ( options . unmount ) options . unmount ( vnode ) ;
695
697
696
- if ( ( r = vnode . ref ) ) {
697
- if ( ! r . current || r . current == vnode . _dom ) {
698
- applyRef ( r , NULL , parentVNode ) ;
699
- }
698
+ if ( ( r = vnode . ref ) && ( ! r . current || r . current == vnode . _dom ) ) {
699
+ applyRef ( r , NULL , parentVNode ) ;
700
700
}
701
701
702
702
if ( ( r = vnode . _component ) != NULL ) {
0 commit comments