-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Closed
Labels
has workaroundA workaround has been found to avoid the problemA workaround has been found to avoid the problem🔩 p2-edge-case
Description
Vue version
v3.6.0-beta.5
Link to minimal reproduction
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:
[ "foo", "bar" ]
... 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:
[ "foo", "bar", "baz" ]
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
has workaroundA workaround has been found to avoid the problemA workaround has been found to avoid the problem🔩 p2-edge-case