Skip to content

Commit 91acabd

Browse files
authored
docs (#162): add fragments to migration section
* docs (#162): add fragments to migration section * fix: code example syntax highlighting error * fix (#162): incorrect comment type * docs (#162): remove inheritattrs since its automatically disabled * docs (#162): link fragments in intro and reorder section
1 parent 34d102c commit 91acabd

File tree

4 files changed

+55
-19
lines changed

4 files changed

+55
-19
lines changed

src/.vuepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ const sidebar = {
9494
'migration/functional-components',
9595
'migration/async-components',
9696
'migration/custom-directives',
97+
'migration/fragments',
9798
'migration/render-function-api',
9899
'migration/slots-unification',
99100
'migration/keycode-modifiers'

src/guide/component-props.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ app.component('custom-layout', {
324324
template: `
325325
<header>...</header>
326326
<main v-bind="$attrs">...</main>
327-
<footer...></footer>
327+
<footer>...</footer>
328328
`
329329
})
330330
```

src/guide/migration/fragments.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Fragments
2+
3+
## Overview
4+
5+
In Vue 3, components now have official support for multi-root node components, i.e., fragments!
6+
7+
## Previous Syntax
8+
9+
In 2.x, multi-root components were not supported and would emit a warning when a user accidentally created one. As a result, many components are wrapped in a single `<div>` in order to fix this error.
10+
11+
```html
12+
<!-- Layout.vue -->
13+
<template>
14+
<div>
15+
<header>...</header>
16+
<main>...</main>
17+
<footer>...</footer>
18+
</div>
19+
</template>
20+
```
21+
22+
## Current Syntax
23+
24+
In 3.x, components now can have multiple root nodes! However, this does require developers to explicitly define where attributes should be distributed.
25+
26+
```html
27+
<!-- Layout.vue -->
28+
<template>
29+
<header>...</header>
30+
<main v-bind="$attrs">...</main>
31+
<footer>...</footer>
32+
</template>
33+
```
34+
35+
For more information on how attribute inheritance works, see [Non-Prop Attributes](/guide/component-props.html#disabling-attribute-inheritance).

src/guide/migration/introduction.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@ We're glad you asked! The answer is no. We've gone to great lengths to ensure mo
88

99
Possibly the biggest change is our new Composition API, which is entirely additive- the previous Options API will continue to be supported, as the Composition API is an advanced feature.
1010

11+
## Overview
12+
13+
### New Features
14+
15+
Some of the new features to keep an eye on in Vue 3 include:
16+
17+
- [Composition API](/guide/composition-api-introduction.html)
18+
- [Teleport](/guide/teleport)
19+
- [Fragments](/guide/migration/fragments)
20+
- [Emits Component Option](/guide/component-custom-events.html)
21+
- `createRenderer` API from `@vue/runtime-core` to create custom renderers
22+
23+
### Breaking
24+
25+
The following consists a list of breaking changes from v2:
26+
27+
- **keyCode support as `v-on` modifiers.** For more information, [see in-depth explanation](/guides/migration/keycodes.html)
28+
1129
## FAQ
1230

1331
> Where should I start in a migration?
@@ -37,21 +55,3 @@ It depends on a few factors:
3755
> If I upgrade to Vue 3, will I also have to upgrade Vuex and Vue Router?
3856
3957
[//]: # 'TODO: still need to see where this lands'
40-
41-
## Overview
42-
43-
### New Features
44-
45-
Some of the new features to keep an eye on in Vue 3 include:
46-
47-
- [Composition API](/guide/composition-api-introduction.html)
48-
- [Teleport](/guide/teleport)
49-
- Fragments
50-
- [Emits Component Option](/guide/component-custom-events.html)
51-
- `createRenderer` API from `@vue/runtime-core` to create custom renderers
52-
53-
### Breaking
54-
55-
The following consists a list of breaking changes from v2:
56-
57-
- **keyCode support as `v-on` modifiers.** For more information, [see in-depth explanation](/guides/migration/keycodes.html)

0 commit comments

Comments
 (0)