Skip to content

Commit 514943e

Browse files
docs: add transition as root to the migration guide (#1067)
1 parent 6730d26 commit 514943e

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

src/.vuepress/config.js

+1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ const sidebar = {
202202
'/guide/migration/slots-unification',
203203
'/guide/migration/suspense',
204204
'/guide/migration/transition',
205+
'/guide/migration/transition-as-root',
205206
'/guide/migration/transition-group',
206207
'/guide/migration/v-on-native-modifier-removed',
207208
'/guide/migration/v-model',
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
badges:
3+
- breaking
4+
---
5+
6+
# Transition as Root <MigrationBadges :badges="$frontmatter.badges" />
7+
8+
## Overview
9+
10+
Using a `<transition>` as a component's root will no longer trigger transitions when the component is toggled from the outside.
11+
12+
## 2.x Behavior
13+
14+
In Vue 2, it was possible to trigger a transition from outside a component by using a `<transition>` as the component's root:
15+
16+
```html
17+
<!-- modal component -->
18+
<template>
19+
<transition>
20+
<div class="modal"><slot/></div>
21+
</transition>
22+
</template>
23+
```
24+
25+
```html
26+
<!-- usage -->
27+
<modal v-if="showModal">hello</modal>
28+
```
29+
30+
Toggling the value of `showModal` would trigger a transition inside the modal component.
31+
32+
This worked by accident, not by design. A `<transition>` is supposed to be triggered by changes to its children, not by toggling the `<transition>` itself.
33+
34+
This quirk has now been removed.
35+
36+
## Migration Strategy
37+
38+
A similar effect can be achieved by passing a prop to the component instead:
39+
40+
```vue
41+
<template>
42+
<transition>
43+
<div v-if="show" class="modal"><slot/></div>
44+
</transition>
45+
</template>
46+
<script>
47+
export default {
48+
props: ['show']
49+
}
50+
</script>
51+
```
52+
53+
```html
54+
<!-- usage -->
55+
<modal :show="showModal">hello</modal>
56+
```
57+
58+
## See also
59+
60+
- [Some transition classes got a rename](/guide/migration/transition.html)
61+
- [`<TransitionGroup>` now renders no wrapper element by default](/guide/migration/transition-group.html)

src/guide/migration/transition-group.md

+1
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ In Vue 3, we have [fragment support](/guide/migration/fragments.html), so compon
3838
## See also
3939

4040
- [Some transition classes got a rename](/guide/migration/transition.html)
41+
- [`<Transition>` as a root can no longer be toggled from the outside](/guide/migration/transition-as-root.html)

src/guide/migration/transition.md

+1
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,5 @@ The `<transition>` component's related prop names are also changed:
6363

6464
## See also
6565

66+
- [`<Transition>` as a root can no longer be toggled from the outside](/guide/migration/transition-as-root.html)
6667
- [`<TransitionGroup>` now renders no wrapper element by default](/guide/migration/transition-group.html)

0 commit comments

Comments
 (0)