chore: improve `renderComponentRoot` warn message (#10914)

This commit is contained in:
btea 2024-10-14 10:14:32 +08:00 committed by GitHub
parent 4e19a99461
commit a038505c65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View File

@ -6,6 +6,7 @@
import { import {
Fragment, Fragment,
type FunctionalComponent, type FunctionalComponent,
Teleport,
createBlock, createBlock,
createCommentVNode, createCommentVNode,
createElementBlock, createElementBlock,
@ -391,6 +392,26 @@ describe('attribute fallthrough', () => {
expect(`Extraneous non-emits event listeners`).toHaveBeenWarned() expect(`Extraneous non-emits event listeners`).toHaveBeenWarned()
}) })
it('should warn when fallthrough fails on teleport root node', () => {
const Parent = {
render() {
return h(Child, { class: 'parent' })
},
}
const root = document.createElement('div')
const Child = defineComponent({
render() {
return h(Teleport, { to: root }, h('div'))
},
})
document.body.appendChild(root)
render(h(Parent), root)
expect(`Extraneous non-props attributes (class)`).toHaveBeenWarned()
})
it('should dedupe same listeners when $attrs is used during render', () => { it('should dedupe same listeners when $attrs is used during render', () => {
const click = vi.fn() const click = vi.fn()
const count = ref(0) const count = ref(0)

View File

@ -190,7 +190,7 @@ export function renderComponentRoot(
`Extraneous non-props attributes (` + `Extraneous non-props attributes (` +
`${extraAttrs.join(', ')}) ` + `${extraAttrs.join(', ')}) ` +
`were passed to component but could not be automatically inherited ` + `were passed to component but could not be automatically inherited ` +
`because component renders fragment or text root nodes.`, `because component renders fragment or text or teleport root nodes.`,
) )
} }
if (eventAttrs.length) { if (eventAttrs.length) {