Skip to content

Scoped slot transforms array argument if rendered conditionally #15048

Description

@Truevoly

Vue version

3.5.0

Link to minimal reproduction

https://play.vuejs.org/#eNqFUk1v00AQ/SvDXgxSYqsEDgSnEqBKwAEQReLAoiq1J+m2+6XdtZvK8n/v7Dp2oyptb7Pz3s68mTcd+2Rt3jbIlqz0lRM2gMfQ2FOuhbLGBejA4QZ62DijICNqNkFfjLL7fF7ER6yUfeSa68poH0D5Lazi/9fZV5TSwF/jZP0qe8N1WQztqBE9Aior1wHpBVCmuu3cSxNWnAkCPWcJAug6SAno+8RNfQkri4MabMaCJwkbsc2vvdE0XRfZnFXEFhLdTxsESeRsCQmJ2JoU3n5PueAanI356gqrmyP5a7+LOc5+OfToWuRswsLabTEM8Nn5D9xRPIHK1I0k9jPgb/RGNlHjQPvc6JpkH/CS2m/JCKG3f/zZLqD241BRaGT2ic8ZGRMX9dToD3IX+bv0j+uetjiaeuQ8BocHL1bwL4vRSTaDFLwdg0X2n+7hObNr0e6tLb1d69Nzcp1ORtfosAZtnKJJ76hCBMtLB8VEj8x2fil0/XAme7gsxrqxAfhwJ5FIiuYUeh6MXcKJQzWd1bHeNGEt4q5eECA2B+1f0PP4TC9adNE0WvAif58vPrD+HmmCLos=

Steps to reproduce

  1. Create a component with a scoped slot that is rendered conditionally
  2. Pass an array as the sole argument to the slot

What is expected?

Array is rendered normally.
If you render items of that array in v-for loop, you only see items inside that array

What is actually happening?

Array is transformed into object. Items and their indexes are staying the same, key field is added

Image

System Info

Any additional comments?

key attribute is generated by the compiler for the slot rendered with v-if.

Image

While this is not explicitly mentioned in documentation, one can assume that the expectation is that slotProps is always an object, as this is what will be passed to the slot if you use multiple v-bind directives on the slot.
This issue is rather pointing out the difference in behavior of the slot when v-if is present or not present.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 p3-minor-bugPriority 3: this fixes a bug, but is an edge case that only affects very specific usage.scope: compiler

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions