Skip to content

Bug: [Vue warn] Non-function value encountered for default slot on stubbed teleport #1829

@freakzlike

Description

@freakzlike

Describe the bug
After update from 2.1.0 to 2.2.0, tests with stubs: { teleport: true } produce a warning:

[Vue warn]: Non-function value encountered for default slot. Prefer function slots for better performance.
  at <Teleport to="body" >
  at <Anonymous ref="VTU_COMPONENT" >
  at <VTUROOT>         

To Reproduce
Able to reproduce within VTU unit test

it('opts in to stubbing teleport ', () => {
const Comp = {
template: `<teleport to="body"><div id="content" /></teleport>`
}
const wrapper = mount(Comp, {
global: {
stubs: {
teleport: true
}
}
})
expect(wrapper.html()).toBe(
'<teleport-stub to="body">\n' +
' <div id="content"></div>\n' +
'</teleport-stub>'
)
})

Expected behavior
Not print a warning

Related information:

  • @vue/test-utils version: 2.2.0
  • Vue version: 3.2.41
  • node version: 16.18.0
  • npm (or yarn) version: pnpm@7.14.0

Additional context
I think this might come from the stubs refactoring and some previous special handling on the teleport child nodes, where they have been explicit passed as function:

() => children

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy