Skip to content

Commit 3684d65

Browse files
committed
test: add test case
1 parent 585eabe commit 3684d65

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,30 @@ describe('defineCustomElement', () => {
791791
assertStyles(el, [`div { color: blue; }`, `div { color: red; }`])
792792
})
793793

794+
test("child components should not inject styles to root element's shadow root w/ shadowRoot false", async () => {
795+
const Bar = defineComponent({
796+
styles: [`div { color: green; }`],
797+
render() {
798+
return 'bar'
799+
},
800+
})
801+
const Baz = () => h(Bar)
802+
const Foo = defineCustomElement(
803+
{
804+
render() {
805+
return [h(Baz)]
806+
},
807+
},
808+
{ shadowRoot: false },
809+
)
810+
811+
customElements.define('my-foo-with-shadowroot-false', Foo)
812+
container.innerHTML = `<my-foo-with-shadowroot-false></my-foo-with-shadowroot-false>`
813+
const el = container.childNodes[0] as VueElement
814+
const style = el.shadowRoot?.querySelector('style')
815+
expect(style).toBeUndefined()
816+
})
817+
794818
test('with nonce', () => {
795819
const Foo = defineCustomElement(
796820
{

0 commit comments

Comments
 (0)