Skip to content

Commit

Permalink
test: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
edison1105 committed Jan 22, 2025
1 parent 585eabe commit 3684d65
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/runtime-dom/__tests__/customElement.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,30 @@ describe('defineCustomElement', () => {
assertStyles(el, [`div { color: blue; }`, `div { color: red; }`])
})

test("child components should not inject styles to root element's shadow root w/ shadowRoot false", async () => {
const Bar = defineComponent({
styles: [`div { color: green; }`],
render() {
return 'bar'
},
})
const Baz = () => h(Bar)
const Foo = defineCustomElement(
{
render() {
return [h(Baz)]
},
},
{ shadowRoot: false },
)

customElements.define('my-foo-with-shadowroot-false', Foo)
container.innerHTML = `<my-foo-with-shadowroot-false></my-foo-with-shadowroot-false>`
const el = container.childNodes[0] as VueElement
const style = el.shadowRoot?.querySelector('style')
expect(style).toBeUndefined()
})

test('with nonce', () => {
const Foo = defineCustomElement(
{
Expand Down

0 comments on commit 3684d65

Please sign in to comment.