@@ -89,8 +89,11 @@ export function diff(
8989
9090 outer: if ( typeof newType == 'function' ) {
9191 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 ;
9497 const isClassComponent =
9598 'prototype' in newType && newType . prototype . render ;
9699
@@ -109,7 +112,6 @@ export function diff(
109112 c = newVNode . _component = oldVNode . _component ;
110113 if ( c . _bits & COMPONENT_PENDING_ERROR ) {
111114 c . _bits |= COMPONENT_PROCESSING_EXCEPTION ;
112- clearProcessingException = true ;
113115 }
114116 } else {
115117 // Instantiate the new component
@@ -132,7 +134,6 @@ export function diff(
132134 if ( ! c . state ) c . state = { } ;
133135 c . context = componentContext ;
134136 c . _globalContext = globalContext ;
135- isNew = true ;
136137 c . _bits |= COMPONENT_DIRTY ;
137138 c . _renderCallbacks = [ ] ;
138139 c . _stateCallbacks = [ ] ;
@@ -159,7 +160,7 @@ export function diff(
159160 c . _vnode = newVNode ;
160161
161162 // Invoke pre-render lifecycle methods
162- if ( isNew ) {
163+ if ( ! oldVNode . _component ) {
163164 if (
164165 isClassComponent &&
165166 newType . getDerivedStateFromProps == NULL &&
@@ -269,21 +270,24 @@ export function diff(
269270 globalContext = assign ( { } , globalContext , c . getChildContext ( ) ) ;
270271 }
271272
272- if ( isClassComponent && ! isNew && c . getSnapshotBeforeUpdate != NULL ) {
273+ if (
274+ isClassComponent &&
275+ oldVNode . _component &&
276+ c . getSnapshotBeforeUpdate != NULL
277+ ) {
273278 snapshot = c . getSnapshotBeforeUpdate ( oldProps , oldState ) ;
274279 }
275280
276281 let isTopLevelFragment =
277282 tmp != NULL && tmp . type === Fragment && tmp . key == NULL ;
278- let renderResult = tmp ;
279283
280284 if ( isTopLevelFragment ) {
281- renderResult = cloneNode ( tmp . props . children ) ;
285+ tmp = cloneNode ( tmp . props . children ) ;
282286 }
283287
284288 oldDom = diffChildren (
285289 parentDom ,
286- isArray ( renderResult ) ? renderResult : [ renderResult ] ,
290+ isArray ( tmp ) ? tmp : [ tmp ] ,
287291 newVNode ,
288292 oldVNode ,
289293 globalContext ,
@@ -303,7 +307,7 @@ export function diff(
303307 commitQueue . push ( c ) ;
304308 }
305309
306- if ( clearProcessingException ) {
310+ if ( c . _bits & COMPONENT_PENDING_ERROR ) {
307311 c . _bits &= ~ ( COMPONENT_PROCESSING_EXCEPTION | COMPONENT_PENDING_ERROR ) ;
308312 }
309313 } catch ( e ) {
@@ -664,13 +668,11 @@ function diffElementNodes(
664668export function applyRef ( ref , value , vnode ) {
665669 try {
666670 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' ) {
670672 ref . _unmount ( ) ;
671673 }
672674
673- if ( ! hasRefUnmount || value != NULL ) {
675+ if ( typeof ref . _unmount != 'function' || value != NULL ) {
674676 // Store the cleanup function on the function
675677 // instance object itself to avoid shape
676678 // transitioning vnode
@@ -693,10 +695,8 @@ export function unmount(vnode, parentVNode, skipRemove) {
693695 let r ;
694696 if ( options . unmount ) options . unmount ( vnode ) ;
695697
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 ) ;
700700 }
701701
702702 if ( ( r = vnode . _component ) != NULL ) {
0 commit comments