File tree Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -5,12 +5,15 @@ import {
5
5
getCurrentInstance ,
6
6
h ,
7
7
inject ,
8
+ nextTick ,
8
9
nodeOps ,
10
+ onMounted ,
9
11
provide ,
10
12
ref ,
11
13
resolveComponent ,
12
14
resolveDirective ,
13
15
serializeInner ,
16
+ watch ,
14
17
withDirectives ,
15
18
} from '@vue/runtime-test'
16
19
@@ -551,6 +554,35 @@ describe('api: createApp', () => {
551
554
) . not . toHaveBeenWarned ( )
552
555
} )
553
556
557
+ // #10005
558
+ test ( 'flush order edge case on nested createApp' , async ( ) => {
559
+ const order : string [ ] = [ ]
560
+ const App = defineComponent ( {
561
+ setup ( props ) {
562
+ const message = ref ( 'm1' )
563
+ watch (
564
+ message ,
565
+ ( ) => {
566
+ order . push ( 'post watcher' )
567
+ } ,
568
+ { flush : 'post' } ,
569
+ )
570
+ onMounted ( ( ) => {
571
+ message . value = 'm2'
572
+ createApp ( ( ) => '' ) . mount ( nodeOps . createElement ( 'div' ) )
573
+ } )
574
+ return ( ) => {
575
+ order . push ( 'render' )
576
+ return h ( 'div' , [ message . value ] )
577
+ }
578
+ } ,
579
+ } )
580
+
581
+ createApp ( App ) . mount ( nodeOps . createElement ( 'div' ) )
582
+ await nextTick ( )
583
+ expect ( order ) . toMatchObject ( [ 'render' , 'render' , 'post watcher' ] )
584
+ } )
585
+
554
586
// config.compilerOptions is tested in packages/vue since it is only
555
587
// supported in the full build.
556
588
} )
Original file line number Diff line number Diff line change @@ -2348,6 +2348,7 @@ function baseCreateRenderer(
2348
2348
return hostNextSibling ( ( vnode . anchor || vnode . el ) ! )
2349
2349
}
2350
2350
2351
+ let isFlushing = false
2351
2352
const render : RootRenderFunction = ( vnode , container , namespace ) => {
2352
2353
if ( vnode == null ) {
2353
2354
if ( container . _vnode ) {
@@ -2364,8 +2365,12 @@ function baseCreateRenderer(
2364
2365
namespace ,
2365
2366
)
2366
2367
}
2367
- flushPreFlushCbs ( )
2368
- flushPostFlushCbs ( )
2368
+ if ( ! isFlushing ) {
2369
+ isFlushing = true
2370
+ flushPreFlushCbs ( )
2371
+ flushPostFlushCbs ( )
2372
+ isFlushing = false
2373
+ }
2369
2374
container . _vnode = vnode
2370
2375
}
2371
2376
You can’t perform that action at this time.
0 commit comments