Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/corePublic

Commitddc1bae

Browse files
authored
feat(runtime-vapor): support render block in createDynamicComponent (#14213)
1 parent624fa7e commitddc1bae

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

‎packages/runtime-vapor/__tests__/apiCreateDynamicComponent.spec.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,15 @@ describe('api: createDynamicComponent', () => {
179179
'<div><span>hi</span><!--slot--></div><!--dynamic-component-->',
180180
)
181181
})
182+
183+
test('accept blocks',async()=>{
184+
const{ html}=define({
185+
setup(){
186+
constn0=template('<a>router link</a>')()
187+
returncreateDynamicComponent(()=>n0)
188+
},
189+
}).render()
190+
191+
expect(html()).toBe('<a>router link</a><!--dynamic-component-->')
192+
})
182193
})

‎packages/runtime-vapor/src/apiCreateDynamicComponent.ts‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import{currentInstance,resolveDynamicComponent}from'@vue/runtime-dom'
2-
import{insert}from'./block'
2+
import{insert,isBlock}from'./block'
33
import{createComponentWithFallback,emptyContext}from'./component'
44
import{renderEffect}from'./renderEffect'
55
importtype{RawProps}from'./componentProps'
@@ -36,14 +36,17 @@ export function createDynamicComponent(
3636
(currentInstance&&currentInstance.appContext)||emptyContext
3737
frag.update(
3838
()=>
39-
createComponentWithFallback(
40-
resolveDynamicComponent(value)asany,
41-
rawProps,
42-
rawSlots,
43-
isSingleRoot,
44-
once,
45-
appContext,
46-
),
39+
// Support integration with VaporRouterView/VaporRouterLink by accepting blocks
40+
isBlock(value)
41+
?value
42+
:createComponentWithFallback(
43+
resolveDynamicComponent(value)asany,
44+
rawProps,
45+
rawSlots,
46+
isSingleRoot,
47+
once,
48+
appContext,
49+
),
4750
value,
4851
)
4952
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp