File tree Expand file tree Collapse file tree 2 files changed +48
-2
lines changed Expand file tree Collapse file tree 2 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -894,4 +894,47 @@ describe('hot module replacement', () => {
894894 await timeout ( )
895895 expect ( serializeInner ( root ) ) . toBe ( '<div>bar</div>' )
896896 } )
897+
898+ test ( 'rerender for nested component' , ( ) => {
899+ const id = 'child-nested-rerender'
900+ const Foo : ComponentOptions = {
901+ __hmrId : id ,
902+ render ( ) {
903+ return this . $slots . default ( )
904+ } ,
905+ }
906+ createRecord ( id , Foo )
907+
908+ const parentId = 'parent-nested-rerender'
909+ const Parent : ComponentOptions = {
910+ __hmrId : parentId ,
911+ render ( ) {
912+ return h ( Foo , null , {
913+ default : ( ) => this . $slots . default ( ) ,
914+ _ : 3 /* FORWARDED */ ,
915+ } )
916+ } ,
917+ }
918+
919+ const appId = 'app-nested-rerender'
920+ const App : ComponentOptions = {
921+ __hmrId : appId ,
922+ render : ( ) =>
923+ h ( Parent , null , {
924+ default : ( ) => [
925+ h ( Foo , null , {
926+ default : ( ) => [ 'foo' ] ,
927+ } ) ,
928+ ] ,
929+ } ) ,
930+ }
931+ createRecord ( parentId , App )
932+
933+ const root = nodeOps . createElement ( 'div' )
934+ render ( h ( App ) , root )
935+ expect ( serializeInner ( root ) ) . toBe ( 'foo' )
936+
937+ rerender ( id , ( ) => 'bar' )
938+ expect ( serializeInner ( root ) ) . toBe ( 'bar' )
939+ } )
897940} )
Original file line number Diff line number Diff line change 77 type InternalRenderFunction ,
88 isClassComponent ,
99} from './component'
10- import { queueJob , queuePostFlushCb } from './scheduler'
10+ import { SchedulerJobFlags , queueJob , queuePostFlushCb } from './scheduler'
1111import { extend , getGlobalThis } from '@vue/shared'
1212
1313type HMRComponent = ComponentOptions | ClassComponent
@@ -96,7 +96,10 @@ function rerender(id: string, newRender?: Function): void {
9696 instance . renderCache = [ ]
9797 // this flag forces child components with slot content to update
9898 isHmrUpdating = true
99- instance . update ( )
99+ // #13771 don't update if the job is already disposed
100+ if ( ! ( instance . job . flags ! & SchedulerJobFlags . DISPOSED ) ) {
101+ instance . update ( )
102+ }
100103 isHmrUpdating = false
101104 } )
102105}
You can’t perform that action at this time.
0 commit comments