Skip to content

Commit b661cd3

Browse files
committed
test: add test
1 parent f41d16e commit b661cd3

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

packages/runtime-dom/__tests__/customElement.spec.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,44 @@ describe('defineCustomElement', () => {
14301430
app.unmount()
14311431
})
14321432

1433+
test('teleport target is ancestor of custom element host', async () => {
1434+
const Child = defineCustomElement(
1435+
{
1436+
render() {
1437+
return [
1438+
h(Teleport, { to: '#t1' }, [renderSlot(this.$slots, 'header')]),
1439+
]
1440+
},
1441+
},
1442+
{ shadowRoot: false },
1443+
)
1444+
customElements.define('my-el-teleport-child-target', Child)
1445+
1446+
const App = {
1447+
render() {
1448+
return h('div', { id: 't1' }, [
1449+
h('my-el-teleport-child-target', null, {
1450+
default: () => [h('div', { slot: 'header' }, 'header')],
1451+
}),
1452+
])
1453+
},
1454+
}
1455+
const app = createApp(App)
1456+
app.mount(container)
1457+
1458+
const target1 = document.getElementById('t1')!
1459+
expect(target1.outerHTML).toBe(
1460+
`<div id="t1">` +
1461+
`<my-el-teleport-child-target data-v-app="">` +
1462+
`<!--teleport start--><!--teleport end-->` +
1463+
`</my-el-teleport-child-target>` +
1464+
`<div slot="header">header</div>` +
1465+
`</div>`,
1466+
)
1467+
1468+
app.unmount()
1469+
})
1470+
14331471
test('toggle nested custom element with shadowRoot: false', async () => {
14341472
customElements.define(
14351473
'my-el-child-shadow-false',

0 commit comments

Comments
 (0)