From b661cd340281e277da3f32d1f3fff2fbb5a18509 Mon Sep 17 00:00:00 2001 From: daiwei Date: Sat, 4 Oct 2025 11:02:41 +0800 Subject: [PATCH] test: add test --- .../__tests__/customElement.spec.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/packages/runtime-dom/__tests__/customElement.spec.ts b/packages/runtime-dom/__tests__/customElement.spec.ts index 36c9e918c..3e48edffe 100644 --- a/packages/runtime-dom/__tests__/customElement.spec.ts +++ b/packages/runtime-dom/__tests__/customElement.spec.ts @@ -1430,6 +1430,44 @@ describe('defineCustomElement', () => { app.unmount() }) + test('teleport target is ancestor of custom element host', async () => { + const Child = defineCustomElement( + { + render() { + return [ + h(Teleport, { to: '#t1' }, [renderSlot(this.$slots, 'header')]), + ] + }, + }, + { shadowRoot: false }, + ) + customElements.define('my-el-teleport-child-target', Child) + + const App = { + render() { + return h('div', { id: 't1' }, [ + h('my-el-teleport-child-target', null, { + default: () => [h('div', { slot: 'header' }, 'header')], + }), + ]) + }, + } + const app = createApp(App) + app.mount(container) + + const target1 = document.getElementById('t1')! + expect(target1.outerHTML).toBe( + `
` + + `` + + `` + + `` + + `
header
` + + `
`, + ) + + app.unmount() + }) + test('toggle nested custom element with shadowRoot: false', async () => { customElements.define( 'my-el-child-shadow-false',