Skip to content

Commit e527c8c

Browse files
committed
fix(runtime-dom): ensure customElement handles empty props correctly.
fix Scoped attribute in Vue file affects the use of web component #6163
1 parent 25f7a16 commit e527c8c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

+14
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,20 @@ describe('defineCustomElement', () => {
210210
customElements.define('my-el-upgrade', E)
211211
expect(el.shadowRoot.innerHTML).toBe(`foo: hello`)
212212
})
213+
214+
// https://github.com/vuejs/core/issues/6163
215+
test('handle components with no props', async () => {
216+
const E = defineCustomElement({
217+
render() {
218+
return h('div', 'foo')
219+
}
220+
})
221+
customElements.define('my-element-noprops', E)
222+
const el = document.createElement('my-element-noprops')
223+
container.appendChild(el)
224+
await nextTick()
225+
expect(el.shadowRoot!.innerHTML).toMatchInlineSnapshot('"<div>foo</div>"')
226+
})
213227
})
214228

215229
describe('emits', () => {

packages/runtime-dom/src/apiCustomElement.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export class VueElement extends BaseClass {
215215
}).observe(this, { attributes: true })
216216

217217
const resolve = (def: InnerComponentDef) => {
218-
const { props, styles } = def
218+
const { props = {}, styles } = def
219219
const hasOptions = !isArray(props)
220220
const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : []
221221

0 commit comments

Comments
 (0)