Vue version
v3.6.0-beta.5
Link to minimal reproduction
https://play.vuejs.org/#eNp9U8Fu2zAM/RVOG5AEaO2h3XbonGBr0QHdYR26HQWsjkOnSmzJkGQ3q+F/L2VHiWOkuVHke08U+VSz70URVCWyKxaZRIvCgkFbFjMuRV4obaEGjSk0kGqVw4igo13pRuXFNh+E7uCURl+55DJR0pDUk3q+jjVMncbY6hInVI3C7ia6gw4W8yKLLdIJIFqIqg0onJfWKgnfkkwk6ylne7F325Cz2QPKBWp4nMf6EUymbBR2vE4u9HqRa88r+yvhPdGgOhfpXp40KRmFB20NORee5J7UMS5OUVKlZj+UOq36QjIvA0jUjpXCgzw7Y9bQhFOxDFZGSVpe7dCcJYQWGer7wgraAGdX0FZcLc4y9fyzzbm2z3w+ecJkfSS/MhuX4+y3RoO6oofuajbWS7Rd+fbPL9xQvCvmalFmhD5RfECjstL12MGuS7mgtnu4ttu71mdCLv+a241Fafyj2rkTsmnxnJHv3KDeevq+3cvgU8vjsqEpes8O3Q9ZLJduvSTT/wkkclNqjdLekb1jmeDBx+g5X/j69AhpPDn9CYpZXcP9fIWJDdb434w/OGebCTQN+DgKOzsfAQd99PbwNtx32mcNch15aMF/FWq3EBreZfAl+Hg+RxsHn1nzCmENddI=
Steps to reproduce
Slots accessed via $slots normally preserve their order from the template:
<script setup>
import Comp from './Comp.vue';
</script>
<template>
<Comp>
<template #foo>foo</template>
<template #bar>bar</template>
</Comp>
</template>
<!-- Comp.vue -->
<template>
<div>{{ Object.keys($slots) }}</div>
</template>
Rendered as:
... unless they have v-if directive, even if with a constant condition. Such slots are always ending up last, and placed in the order they're rendered:
<script setup>
import Comp from './Comp.vue';
</script>
<template>
<Comp>
<template #foo>foo</template>
<template #baz v-if="true">baz</template>
<template #bar>bar</template>
</Comp>
</template>
<!-- Comp.vue -->
<template>
<div>{{ Object.keys($slots) }}</div>
</template>
Rendered as:
What is expected?
I expect $slots to provide the passed slots in order reflecting their position in the template, regardless of presense of v-if directive.
What is actually happening?
Described in the repro.
System Info
Any additional comments?
I have a component that renders arbitrary number of slots, and it's crucial for preserve their order.
Vue version
v3.6.0-beta.5
Link to minimal reproduction
https://play.vuejs.org/#eNp9U8Fu2zAM/RVOG5AEaO2h3XbonGBr0QHdYR26HQWsjkOnSmzJkGQ3q+F/L2VHiWOkuVHke08U+VSz70URVCWyKxaZRIvCgkFbFjMuRV4obaEGjSk0kGqVw4igo13pRuXFNh+E7uCURl+55DJR0pDUk3q+jjVMncbY6hInVI3C7ia6gw4W8yKLLdIJIFqIqg0onJfWKgnfkkwk6ylne7F325Cz2QPKBWp4nMf6EUymbBR2vE4u9HqRa88r+yvhPdGgOhfpXp40KRmFB20NORee5J7UMS5OUVKlZj+UOq36QjIvA0jUjpXCgzw7Y9bQhFOxDFZGSVpe7dCcJYQWGer7wgraAGdX0FZcLc4y9fyzzbm2z3w+ecJkfSS/MhuX4+y3RoO6oofuajbWS7Rd+fbPL9xQvCvmalFmhD5RfECjstL12MGuS7mgtnu4ttu71mdCLv+a241Fafyj2rkTsmnxnJHv3KDeevq+3cvgU8vjsqEpes8O3Q9ZLJduvSTT/wkkclNqjdLekb1jmeDBx+g5X/j69AhpPDn9CYpZXcP9fIWJDdb434w/OGebCTQN+DgKOzsfAQd99PbwNtx32mcNch15aMF/FWq3EBreZfAl+Hg+RxsHn1nzCmENddI=
Steps to reproduce
Slots accessed via
$slotsnormally preserve their order from the template:Rendered as:
... unless they have
v-ifdirective, even if with a constant condition. Such slots are always ending up last, and placed in the order they're rendered:Rendered as:
What is expected?
I expect
$slotsto provide the passed slots in order reflecting their position in the template, regardless of presense ofv-ifdirective.What is actually happening?
Described in the repro.
System Info
Any additional comments?
I have a component that renders arbitrary number of slots, and it's crucial for preserve their order.