Skip to content

Commit 7e484c3

Browse files
LinusBorgThorsten Luenborgsdras
authored
feat(migration): transition-group (close #648) (#649)
* feat(migration): transition-group document fragment default behaviour * Update src/guide/migration/transition-group.md * Update src/guide/migration/transition-group.md * Update src/guide/migration/transition-group.md * Update src/guide/migration/transition-group.md * Update src/guide/transitions-list.md * Update src/guide/migration/transition-group.md * add transition-group to config Co-authored-by: Thorsten Luenborg <[email protected]> Co-authored-by: Sarah Drasner <[email protected]>
1 parent a74bfed commit 7e484c3

File tree

6 files changed

+50
-4
lines changed

6 files changed

+50
-4
lines changed

src/.vuepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ const sidebar = {
139139
'/guide/migration/render-function-api',
140140
'/guide/migration/slots-unification',
141141
'/guide/migration/transition',
142+
'/guide/migration/transition-group',
142143
'/guide/migration/v-on-native-modifier-removed',
143144
'/guide/migration/v-model',
144145
'/guide/migration/v-if-v-for',

src/api/built-in-components.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107

108108
- **Props:**
109109

110-
- `tag` - `string`, defaults to `span`.
110+
- `tag` - `string`, if not defined, renders without a root element.
111111
- `move-class` - overwrite CSS class applied during moving transition.
112112
- exposes the same props as `<transition>` except `mode`.
113113

@@ -117,7 +117,7 @@
117117

118118
- **Usage:**
119119

120-
`<transition-group>` serve as transition effects for **multiple** elements/components. The `<transition-group>` renders a real DOM element. By default it renders a `<span>`, and you can configure what element it should render via the `tag` attribute.
120+
`<transition-group>` provides transition effects for **multiple** elements/components. By default it doesn't render a wrapper DOM element, but one can be defined via the `tag` attribute.
121121

122122
Note that every child in a `<transition-group>` must be [**uniquely keyed**](./special-attributes.html#key) for the animations to work properly.
123123

src/guide/migration/introduction.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ The following consists a list of breaking changes from 2.x:
101101
- [The `data` option from mixins is now merged shallowly](/guide/migration/data-option.html#mixin-merge-behavior-change)
102102
- [Attributes coercion strategy changed](/guide/migration/attribute-coercion.html)
103103
- [Some transition classes got a rename](/guide/migration/transition.html)
104+
- [`<TransitionGroup>` now renders no wrapper element by default](/guide/migration/transition-group.html)
104105
- [When watching an array, the callback will only trigger when the array is replaced. If you need to trigger on mutation, the `deep` option must be specified.](/guide/migration/watch.html)
105106
- `<template>` tags with no special directives (`v-if/else-if/else`, `v-for`, or `v-slot`) are now treated as plain elements and will result in a native `<template>` element instead of rendering its inner content.
106107
- In Vue 2.x, application root container's `outerHTML` is replaced with root component template (or eventually compiled to a template, if root component has no template/render option). Vue 3.x now uses application container's `innerHTML` instead - this means the container itself is no longer considered part of the template.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Transition Group Root Element
3+
badges:
4+
- breaking
5+
---
6+
7+
# {{ $frontmatter.title }} <MigrationBadges :badges="$frontmatter.badges" />
8+
9+
## Overview
10+
11+
`<transition-group>` no longer renders a root element by default, but can still create one with the `tag` prop.
12+
13+
## 2.x Syntax
14+
15+
In Vue 2, `<transition-group>`, like other custom components, needed a root element, which by default was a `<span>` but was customizable via the `tag` prop.
16+
17+
```html
18+
<transition-group tag="ul">
19+
<li v-for="item in items" :key="item">
20+
{{ item }}
21+
</li>
22+
</transition-group>
23+
```
24+
25+
## 3.x Syntax
26+
27+
In Vue 3, we have [fragment support](/guide/migration/fragments.html), so components no longer _need_ a root node. Consequently, `<transition-group>` no longer renders one by default.
28+
29+
- If you already have the `tag` prop defined in your Vue 2 code, like in the example above, everything will work as before
30+
- If you didn't have one defined _and_ your styling or other behaviors relied on the presence of the `<span>` root element to work properly, simply add `tag="span"` to the `<transition-group>`:
31+
32+
```html
33+
<transition-group tag="span">
34+
<!-- -->
35+
</transition-group>
36+
```
37+
38+
## See also
39+
40+
- [Some transition classes got a rename](/guide/migration/transition.html)

src/guide/migration/transition.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,8 @@ The `<transition>` component's related prop names are also changed:
5959

6060
1. Replace instances of `.v-enter` to `.v-enter-from`
6161
2. Replace instances of `.v-leave` to `.v-leave-from`
62-
3. Replace instances of related prop names, as above.
62+
3. Replace instances of related prop names, as above.
63+
64+
## See also
65+
66+
- [`<TransitionGroup>` now renders no wrapper element by default](/guide/migration/transition-group.html)

src/guide/transitions-list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ So far, we've managed transitions for:
77

88
So what about for when we have a whole list of items we want to render simultaneously, for example with `v-for`? In this case, we'll use the `<transition-group>` component. Before we dive into an example though, there are a few things that are important to know about this component:
99

10-
- Unlike `<transition>`, it renders an actual element: a `<span>` by default. You can change the element that's rendered with the `tag` attribute.
10+
- By default, it doesn't render a wrapper element, but you can specify an element to be rendered with the `tag` attribute.
1111
- [Transition modes](/guide/transitions-enterleave#transition-modes) are not available, because we are no longer alternating between mutually exclusive elements.
1212
- Elements inside are **always required** to have a unique `key` attribute.
1313
- CSS transition classes will be applied to inner elements and not to the group/container itself.

0 commit comments

Comments
 (0)