Skip to content

Commit a038505

Browse files
authored
chore: improve renderComponentRoot warn message (#10914)
1 parent 4e19a99 commit a038505

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

packages/runtime-core/__tests__/rendererAttrsFallthrough.spec.ts

+21
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import {
77
Fragment,
88
type FunctionalComponent,
9+
Teleport,
910
createBlock,
1011
createCommentVNode,
1112
createElementBlock,
@@ -391,6 +392,26 @@ describe('attribute fallthrough', () => {
391392
expect(`Extraneous non-emits event listeners`).toHaveBeenWarned()
392393
})
393394

395+
it('should warn when fallthrough fails on teleport root node', () => {
396+
const Parent = {
397+
render() {
398+
return h(Child, { class: 'parent' })
399+
},
400+
}
401+
const root = document.createElement('div')
402+
403+
const Child = defineComponent({
404+
render() {
405+
return h(Teleport, { to: root }, h('div'))
406+
},
407+
})
408+
409+
document.body.appendChild(root)
410+
render(h(Parent), root)
411+
412+
expect(`Extraneous non-props attributes (class)`).toHaveBeenWarned()
413+
})
414+
394415
it('should dedupe same listeners when $attrs is used during render', () => {
395416
const click = vi.fn()
396417
const count = ref(0)

packages/runtime-core/src/componentRenderUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export function renderComponentRoot(
190190
`Extraneous non-props attributes (` +
191191
`${extraAttrs.join(', ')}) ` +
192192
`were passed to component but could not be automatically inherited ` +
193-
`because component renders fragment or text root nodes.`,
193+
`because component renders fragment or text or teleport root nodes.`,
194194
)
195195
}
196196
if (eventAttrs.length) {

0 commit comments

Comments
 (0)