]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: improve `renderComponentRoot` warn message (#10914)
authorbtea <2356281422@qq.com>
Mon, 14 Oct 2024 02:14:32 +0000 (10:14 +0800)
committerGitHub <noreply@github.com>
Mon, 14 Oct 2024 02:14:32 +0000 (10:14 +0800)
packages/runtime-core/__tests__/rendererAttrsFallthrough.spec.ts
packages/runtime-core/src/componentRenderUtils.ts

index 9c985379c1e90d4a459d07b1d5ddf4a28db448c7..45d00579feeb7149400517f2dc0f79ed0f01086c 100644 (file)
@@ -6,6 +6,7 @@
 import {
   Fragment,
   type FunctionalComponent,
+  Teleport,
   createBlock,
   createCommentVNode,
   createElementBlock,
@@ -391,6 +392,26 @@ describe('attribute fallthrough', () => {
     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', () => {
     const click = vi.fn()
     const count = ref(0)
index a15d18d56bf70b7b74a96926174446afae4ab4c9..a1afae6201a57033b70829aba8f68f86537c3c4e 100644 (file)
@@ -190,7 +190,7 @@ export function renderComponentRoot(
             `Extraneous non-props attributes (` +
               `${extraAttrs.join(', ')}) ` +
               `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) {