Skip to content

Commit f6eaa88

Browse files
committed
wip: save
1 parent a590cfc commit f6eaa88

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

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

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,46 +1089,46 @@ describe('defineVaporCustomElement', () => {
10891089
assertStyles(el, [`div { color: blue; }`, `div { color: red; }`])
10901090
})
10911091

1092-
// test("child components should not inject styles to root element's shadow root w/ shadowRoot false", async () => {
1093-
// const Bar = defineVaporComponent({
1094-
// styles: [`div { color: green; }`],
1095-
// render() {
1096-
// return 'bar'
1097-
// },
1098-
// })
1099-
// const Baz = () => h(Bar)
1100-
// const Foo = defineVaporCustomElement(
1101-
// {
1102-
// render() {
1103-
// return [h(Baz)]
1104-
// },
1105-
// },
1106-
// { shadowRoot: false },
1107-
// )
1092+
test("child components should not inject styles to root element's shadow root w/ shadowRoot false", async () => {
1093+
const Bar = defineVaporComponent({
1094+
styles: [`div { color: green; }`],
1095+
setup() {
1096+
return template('bar')()
1097+
},
1098+
} as any)
1099+
const Baz = () => createComponent(Bar)
1100+
const Foo = defineVaporCustomElement(
1101+
{
1102+
setup() {
1103+
return [createComponent(Baz)]
1104+
},
1105+
},
1106+
{ shadowRoot: false } as any,
1107+
)
11081108

1109-
// customElements.define('my-foo-with-shadowroot-false', Foo)
1110-
// container.innerHTML = `<my-foo-with-shadowroot-false></my-foo-with-shadowroot-false>`
1111-
// const el = container.childNodes[0] as VaporElement
1112-
// const style = el.shadowRoot?.querySelector('style')
1113-
// expect(style).toBeUndefined()
1114-
// })
1109+
customElements.define('my-foo-with-shadowroot-false', Foo)
1110+
container.innerHTML = `<my-foo-with-shadowroot-false></my-foo-with-shadowroot-false>`
1111+
const el = container.childNodes[0] as VaporElement
1112+
const style = el.shadowRoot?.querySelector('style')
1113+
expect(style).toBeUndefined()
1114+
})
11151115

1116-
// test('with nonce', () => {
1117-
// const Foo = defineVaporCustomElement(
1118-
// {
1119-
// styles: [`div { color: red; }`],
1120-
// render() {
1121-
// return h('div', 'hello')
1122-
// },
1123-
// },
1124-
// { nonce: 'xxx' },
1125-
// )
1126-
// customElements.define('my-el-with-nonce', Foo)
1127-
// container.innerHTML = `<my-el-with-nonce></my-el-with-nonce>`
1128-
// const el = container.childNodes[0] as VaporElement
1129-
// const style = el.shadowRoot?.querySelector('style')!
1130-
// expect(style.getAttribute('nonce')).toBe('xxx')
1131-
// })
1116+
test('with nonce', () => {
1117+
const Foo = defineVaporCustomElement(
1118+
{
1119+
styles: [`div { color: red; }`],
1120+
setup() {
1121+
return template('<div>hello</div>', true)()
1122+
},
1123+
},
1124+
{ nonce: 'xxx' } as any,
1125+
)
1126+
customElements.define('my-el-with-nonce', Foo)
1127+
container.innerHTML = `<my-el-with-nonce></my-el-with-nonce>`
1128+
const el = container.childNodes[0] as VaporElement
1129+
const style = el.shadowRoot?.querySelector('style')!
1130+
expect(style.getAttribute('nonce')).toBe('xxx')
1131+
})
11321132
})
11331133

11341134
// describe('async', () => {

0 commit comments

Comments
 (0)