Skip to content

Commit d15554c

Browse files
committed
test: add test
1 parent 0f595ec commit d15554c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,33 @@ describe('defineCustomElement', () => {
638638
`<div><slot><div>fallback</div></slot></div><div><slot name="named"></slot></div>`,
639639
)
640640
})
641+
642+
test('render slot props', async () => {
643+
const foo = ref('foo')
644+
const E = defineCustomElement({
645+
render() {
646+
return [
647+
h(
648+
'div',
649+
null,
650+
renderSlot(this.$slots, 'default', { class: foo.value }),
651+
),
652+
]
653+
},
654+
})
655+
customElements.define('my-el-slot-props', E)
656+
container.innerHTML = `<my-el-slot-props><span>hi</span></my-el-slot-props>`
657+
const e = container.childNodes[0] as VueElement
658+
expect(e.shadowRoot!.innerHTML).toBe(
659+
`<div><slot class="foo"></slot></div>`,
660+
)
661+
662+
foo.value = 'bar'
663+
await nextTick()
664+
expect(e.shadowRoot!.innerHTML).toBe(
665+
`<div><slot class="bar"></slot></div>`,
666+
)
667+
})
641668
})
642669

643670
describe('provide/inject', () => {

0 commit comments

Comments
 (0)