File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 2
2
type Ref ,
3
3
inject ,
4
4
nextTick ,
5
+ onMounted ,
5
6
onUpdated ,
6
7
provide ,
7
8
ref ,
@@ -13,6 +14,7 @@ import {
13
14
createIf ,
14
15
createTextNode ,
15
16
renderEffect ,
17
+ setInsertionState ,
16
18
template ,
17
19
} from '../src'
18
20
import { makeRender } from './_utils'
@@ -266,6 +268,29 @@ describe('component', () => {
266
268
expect ( spy ) . toHaveBeenCalledTimes ( 2 )
267
269
} )
268
270
271
+ it ( 'properly mount child component when using setInsertionState' , async ( ) => {
272
+ const spy = vi . fn ( )
273
+
274
+ const { component : Comp } = define ( {
275
+ setup ( ) {
276
+ onMounted ( spy )
277
+ return template ( '<h1>hi</h1>' ) ( )
278
+ } ,
279
+ } )
280
+
281
+ const { host } = define ( {
282
+ setup ( ) {
283
+ const n2 = template ( '<div></div>' , true ) ( )
284
+ setInsertionState ( n2 as any )
285
+ createComponent ( Comp )
286
+ return n2
287
+ } ,
288
+ } ) . render ( )
289
+
290
+ expect ( host . innerHTML ) . toBe ( '<div><h1>hi</h1></div>' )
291
+ expect ( spy ) . toHaveBeenCalledTimes ( 1 )
292
+ } )
293
+
269
294
it ( 'unmount component' , async ( ) => {
270
295
const { host, app, instance } = define ( ( ) => {
271
296
const count = ref ( 0 )
Original file line number Diff line number Diff line change @@ -276,7 +276,7 @@ export function createComponent(
276
276
onScopeDispose ( ( ) => unmountComponent ( instance ) , true )
277
277
278
278
if ( ! isHydrating && _insertionParent ) {
279
- insert ( instance . block , _insertionParent , _insertionAnchor )
279
+ mountComponent ( instance , _insertionParent , _insertionAnchor )
280
280
}
281
281
282
282
return instance
You can’t perform that action at this time.
0 commit comments