Skip to content

Commit fcb40f3

Browse files
authored
docs (#174): standardize references to versions (#178)
* docs (#174): standardize previous / current syntax heading * docs (#174): standardize version reference
1 parent 76ca5e7 commit fcb40f3

11 files changed

+58
-58
lines changed

src/guide/migration/async-components.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const asyncPage = {
3030
}
3131
```
3232

33-
## Current Syntax
33+
## 3.x Syntax
3434

3535
Now, in Vue 3, since functional components are defined as pure functions, async components definitions need to be explicitly defined by wrapping it in a new `defineAsyncComponent` helper:
3636

@@ -52,7 +52,7 @@ const asyncPageWithOptions = defineAsyncComponent({
5252
})
5353
```
5454

55-
Another change that has been made from v2 is that the `component` option is now renamed to `loader` in order to accurately communicate that a component definition cannot be provided directly.
55+
Another change that has been made from 2.x is that the `component` option is now renamed to `loader` in order to accurately communicate that a component definition cannot be provided directly.
5656

5757
```js{4}
5858
import { defineAsyncComponent } from 'vue'

src/guide/migration/custom-directives.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Here is a quick summary of what has changed:
99

1010
For more information, read on!
1111

12-
## Previous Syntax
12+
## 2.x Syntax
1313

1414
In Vue 2, custom directives were created by using the hooks listed below to target an element’s lifecycle, all of which are optional:
1515

@@ -35,7 +35,7 @@ Vue.directive('highlight', {
3535

3636
Here, in the initial setup for this element, the directive binds a style by passing in a value, that can be updated to different values through the application.
3737

38-
## Current Syntax
38+
## 3.x Syntax
3939

4040
In Vue 3, however, we’ve created a more cohesive API for custom directives. As you can see, they differ greatly from our component lifecycle methods even though we’re hooking into similar events. We’ve now unified them like so:
4141

src/guide/migration/events-api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ types:
1010

1111
`$on`, `$off` and `$once` instance methods are removed. Vue instances no longer implement the event emitter interface.
1212

13-
## Previous Syntax
13+
## 2.x Syntax
1414

15-
In v2, Vue instance could be used to trigger handlers attached imperatively via the event emitter API (`$on`, `$off` and `$once`). This was used to create _event hubs_ to create global event listeners used across the whole application:
15+
In 2.x, Vue instance could be used to trigger handlers attached imperatively via the event emitter API (`$on`, `$off` and `$once`). This was used to create _event hubs_ to create global event listeners used across the whole application:
1616

1717
```js
1818
// eventHub.js

src/guide/migration/fragments.md

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

55
In Vue 3, components now have official support for multi-root node components, i.e., fragments!
66

7-
## Previous Syntax
7+
## 2.x Syntax
88

99
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.
1010

@@ -19,7 +19,7 @@ In 2.x, multi-root components were not supported and would emit a warning when a
1919
</template>
2020
```
2121

22-
## Current Syntax
22+
## 3.x Syntax
2323

2424
In 3.x, components now can have multiple root nodes! However, this does require developers to explicitly define where attributes should be distributed.
2525

src/guide/migration/functional-components.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
In terms of what has changed, at a high level:
66

7-
- Performance gains from v2 for functional components are now negligible in v3, so we recommend just using stateful components
7+
- Performance gains from 2.x for functional components are now negligible in 3.x, so we recommend just using stateful components
88
- Functional components can only be created using a plain function that receives `props` and `context` (i.e., `slots`, `attrs`, `emit`)
99
- **DEPRECATED:** `functional` attribute on single-file component (SFC) `<template>` is deprecated
1010
- **DEPRECATED:** `{ functional: true }` option in components created by functions is deprecated
@@ -22,9 +22,9 @@ However, in Vue 3, the performance of stateful components has improved to the po
2222

2323
As a result, the only remaining use case for functional components is simple components, such as a component to create a dynamic heading. Otherwise, it is recommended to use stateful components as you normally would.
2424

25-
## Previous Syntax
25+
## 2.x Syntax
2626

27-
Using the `<dynamic-heading>` component, which is responsible for rendering out the appropriate heading (i.e., `h1`, `h2`, `h3`, etc.), this could have been written as a single-file component in v2 as:
27+
Using the `<dynamic-heading>` component, which is responsible for rendering out the appropriate heading (i.e., `h1`, `h2`, `h3`, etc.), this could have been written as a single-file component in 2.x as:
2828

2929
```js
3030
// Vue 2 Functional Component Example
@@ -56,7 +56,7 @@ export default {
5656
</script>
5757
```
5858

59-
## Current Syntax
59+
## 3.x Syntax
6060

6161
### Components Created by Functions
6262

@@ -82,7 +82,7 @@ export default GreetingMessage
8282

8383
### Single File Components (SFCs)
8484

85-
In v3, the performance difference between stateful and functional components has been drastically reduced and will be insignificant in most use cases. As a result, the migration path for developers using `functional` on SFCs is to remove the attribute. No additional work required.
85+
In 3.x, the performance difference between stateful and functional components has been drastically reduced and will be insignificant in most use cases. As a result, the migration path for developers using `functional` on SFCs is to remove the attribute. No additional work required.
8686

8787
Using our `<dynamic-heading>` example from before, here is how it would look now.
8888

src/guide/migration/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Some of the new features to keep an eye on in Vue 3 include:
2222

2323
### Breaking
2424

25-
The following consists a list of breaking changes from v2:
25+
The following consists a list of breaking changes from 2.x:
2626

2727
- **keyCode support as `v-on` modifiers.** For more information, [see in-depth explanation](/guides/migration/keycodes.html)
2828

src/guide/migration/keycode-modifiers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Here is a quick summary of what has changed:
77
- **BREAKING**: Using numbers, i.e. keyCodes, as `v-on` modifiers is no longer supported
88
- **BREAKING**: `config.keyCodes` is no longer supported
99

10-
## Previous Syntax
10+
## 2.x Syntax
1111

1212
In Vue 2, `keyCodes` were supported as a way to modify a `v-on` method.
1313

@@ -35,7 +35,7 @@ Vue.config.keyCodes = {
3535
<input v-on:keyup.f1="showHelpText" />
3636
```
3737

38-
## Current Syntax
38+
## 3.x Syntax
3939

4040
Since [`KeyboardEvent.keyCode` has been deprecated](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode), it no longer makes sense for Vue 3 to continue supporting this as well. As a result, it is now recommended to use the kebab-case name for any key you want to use as a modifier.
4141

src/guide/migration/render-function-api.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ For more information, read on!
1414

1515
## Render Function Argument
1616

17-
### Previous Syntax
17+
### 2.x Syntax
1818

1919
In 2.x, the `render` function would automatically receive the `h` function (which is a conventional alias for `createElement`) as an argument:
2020

@@ -27,7 +27,7 @@ export default {
2727
}
2828
```
2929

30-
### Current Syntax
30+
### 3.x Syntax
3131

3232
In 3.x, `h` is now globally imported instead of being automatically passed as an argument.
3333

@@ -44,7 +44,7 @@ export default {
4444

4545
## Render Function Signature Change
4646

47-
### Previous Syntax
47+
### 2.x Syntax
4848

4949
In 2.x, the `render` function automatically received arguments such as `h`.
5050

@@ -57,7 +57,7 @@ export default {
5757
}
5858
```
5959

60-
### Current Syntax
60+
### 3.x Syntax
6161

6262
In 3.x, since the `render` function no longer receives any arguments, it will primarily be used inside of the `setup()` function. This has the added benefit of gaining access to reactive state and functions declared in scope, as well as the arguments passed to `setup()`.
6363

@@ -75,13 +75,14 @@ export default {
7575
}
7676

7777
// return the render function
78-
return () => h(
79-
'div',
80-
{
81-
onClick: increment
82-
},
83-
state.count
84-
)
78+
return () =>
79+
h(
80+
'div',
81+
{
82+
onClick: increment
83+
},
84+
state.count
85+
)
8586
}
8687
}
8788
```
@@ -90,7 +91,7 @@ For more information on how `setup()` works, see our [Composition API Guide](/gu
9091

9192
## VNode Props Format
9293

93-
### Previous Syntax
94+
### 2.x Syntax
9495

9596
In 2.x, `domProps` contained a nested list within the VNode props:
9697

@@ -106,7 +107,7 @@ In 2.x, `domProps` contained a nested list within the VNode props:
106107
}
107108
```
108109

109-
### Current Syntax
110+
### 3.x Syntax
110111

111112
In 3.x, the entire VNode props structure is flattened. Using the example from above, here is what it would look like now.
112113

src/guide/migration/slots-unification.md

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

33
## Overview
44

5-
This change unifies normal and scoped slots in v3.
5+
This change unifies normal and scoped slots in 3.x.
66

77
Here is a quick summary of what has changed:
88

@@ -11,9 +11,9 @@ Here is a quick summary of what has changed:
1111

1212
For more information, read on!
1313

14-
## Previous Syntax
14+
## 2.x Syntax
1515

16-
When using the render function, i.e., `h`, v2 used to define the `slot` data property on the content nodes.
16+
When using the render function, i.e., `h`, 2.x used to define the `slot` data property on the content nodes.
1717

1818
```js
1919
// 2.x Syntax
@@ -30,9 +30,9 @@ In addition, when referencing scoped slots, they could be referenced using the f
3030
this.$scopedSlots.header
3131
```
3232

33-
## Current Syntax
33+
## 3.x Syntax
3434

35-
In v3, render functions will have a `slots` option where they can be defined instead.
35+
In 3.x, render functions will have a `slots` option where they can be defined instead.
3636

3737
```js
3838
// 3.x Syntax
@@ -58,4 +58,4 @@ this.$slots.header
5858

5959
A majority of the change has already been shipped in 2.6. As a result, the migration can happen in one step:
6060

61-
1. Replace all `this.$scopedSlots` occurrences with `this.$slots` in v3.
61+
1. Replace all `this.$scopedSlots` occurrences with `this.$slots` in 3.x.

src/guide/migration/treeshaking.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Global API Treeshaking
22

3-
## Previous Syntax
3+
## 2.x Syntax
44

55
If you’ve ever had to manually manipulate DOM in Vue, you might have come across this pattern:
66

@@ -20,22 +20,22 @@ import { MyComponent } from './MyComponent.vue'
2020

2121
test('an async feature', async () => {
2222
const wrapper = shallowMount(MyComponent)
23-
23+
2424
// execute some DOM-related tasks
2525

2626
await wrapper.vm.$nextTick()
2727

28-
// run your assertions
28+
// run your assertions
2929
})
3030
```
3131

32-
`Vue.nextTick()` is a global API exposed directly on a single Vue object – in fact, the instance method `$nextTick()` is just a handy wrapper around `Vue.nextTick()` with the callback’s `this` context automatically bound to the current Vue instance for convenience.
32+
`Vue.nextTick()` is a global API exposed directly on a single Vue object – in fact, the instance method `$nextTick()` is just a handy wrapper around `Vue.nextTick()` with the callback’s `this` context automatically bound to the current Vue instance for convenience.
3333

34-
But what if you’ve never had to deal with manual DOM manipulation, nor are you using or testing async components in our app? Or, what if, for whatever reason, you prefer to use the good old `window.setTimeout()` instead? In such a case, the code for `nextTick()` will become dead code – that is, code that’s written but never used. And dead code is hardly a good thing, especially in our client-side context where every kilobyte matters.
34+
But what if you’ve never had to deal with manual DOM manipulation, nor are you using or testing async components in our app? Or, what if, for whatever reason, you prefer to use the good old `window.setTimeout()` instead? In such a case, the code for `nextTick()` will become dead code – that is, code that’s written but never used. And dead code is hardly a good thing, especially in our client-side context where every kilobyte matters.
3535

36-
Module bundlers like [webpack](https://webpack.js.org/) support [tree-shaking](https://webpack.js.org/guides/tree-shaking/), which is a fancy term for “dead code elimination.” Unfortunately, due to how the code is written in previous Vue versions, global APIs like `Vue.nextTick()` are not tree-shakeable and will be included in the final bundle regardless of where they are actually used or not.
36+
Module bundlers like [webpack](https://webpack.js.org/) support [tree-shaking](https://webpack.js.org/guides/tree-shaking/), which is a fancy term for “dead code elimination.” Unfortunately, due to how the code is written in previous Vue versions, global APIs like `Vue.nextTick()` are not tree-shakeable and will be included in the final bundle regardless of where they are actually used or not.
3737

38-
## Current Syntax
38+
## 3.x Syntax
3939

4040
In Vue 3, the global and internal APIs have been restructured with tree-shaking support in mind. As a result, the global APIs can now only be accessed as named exports for the ES Modules build. For example, our previous snippets should now look like this:
4141

@@ -65,21 +65,20 @@ test('an async feature', async () => {
6565
})
6666
```
6767

68-
Calling `Vue.nextTick()` directly will now result in the infamous `undefined is not a function` error.
68+
Calling `Vue.nextTick()` directly will now result in the infamous `undefined is not a function` error.
6969

7070
With this change, provided the module bundler supports tree-shaking, global APIs that are not used in a Vue application will be eliminated from the final bundle, resulting in an optimal file size.
7171

7272
## Affected APIs
7373

7474
These global APIs in Vue 2.x are affected by this change:
7575

76-
* `Vue.nextTick`
77-
* `Vue.observable` (replaced by `Vue.reactive`)
78-
* `Vue.version`
79-
* `Vue.compile` (only in full builds)
80-
* `Vue.set` (only in compat builds)
81-
* `Vue.delete` (only in compat builds)
82-
76+
- `Vue.nextTick`
77+
- `Vue.observable` (replaced by `Vue.reactive`)
78+
- `Vue.version`
79+
- `Vue.compile` (only in full builds)
80+
- `Vue.set` (only in compat builds)
81+
- `Vue.delete` (only in compat builds)
8382

8483
## Internal Helpers
8584

@@ -103,9 +102,9 @@ export function render() {
103102
}
104103
```
105104

106-
This essentially means the `Transition` component only gets imported when the application actually makes use of it. In other words, if the application doesn’t have any `<transition>` component, the code supporting this feature will not be present in the final bundle.
105+
This essentially means the `Transition` component only gets imported when the application actually makes use of it. In other words, if the application doesn’t have any `<transition>` component, the code supporting this feature will not be present in the final bundle.
107106

108-
With global tree-shaking, the user only “pay” for the features they actually use. Even better, knowing that optional features won't increase the bundle size for applications not using them, framework size has become much less a concern for additional core features in the future, if at all.
107+
With global tree-shaking, the user only “pay” for the features they actually use. Even better, knowing that optional features won't increase the bundle size for applications not using them, framework size has become much less a concern for additional core features in the future, if at all.
109108

110109
::: warning Important
111110
The above only applies to the [ES Modules builds](/guide/installation.html#explanation-of-different-builds) for use with tree-shaking capable bundlers - the UMD build still includes all features and exposes everything on the Vue global variable (and the compiler will produce appropriate output to use APIs off the global instead of importing).
@@ -153,7 +152,7 @@ module.exports = {
153152

154153
This will tell webpack to treat the Vue module as an external library and not bundle it.
155154

156-
If your module bundler of choice happens to be [Rollup](https://rollupjs.org/), you basically get the same effect for free, as by default Rollup will treat absolute module IDs (`'vue'` in our case) as external dependencies and not include them in the final bundle. During bundling though, it might emit a [“Treating vue as external dependency”](https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency) warning, which can be suppressed with the `external` option:
155+
If your module bundler of choice happens to be [Rollup](https://rollupjs.org/), you basically get the same effect for free, as by default Rollup will treat absolute module IDs (`'vue'` in our case) as external dependencies and not include them in the final bundle. During bundling though, it might emit a [“Treating vue as external dependency”](https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency) warning, which can be suppressed with the `external` option:
157156

158157
```js
159158
// rollup.config.js

src/guide/migration/v-model.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ In 2.2 we introduced the `model` component option that allows the component to c
2121

2222
With Vue 3, the API for two-way data binding is being standardized in order to reduce confusion and to allow developers more flexibility with the `v-model` directive.
2323

24-
## Previous Syntax
24+
## 2.x Syntax
2525

26-
In v2, using a `v-model` on a component was an equivalent of passing a `value` prop and emitting an `input` event:
26+
In 2.x, using a `v-model` on a component was an equivalent of passing a `value` prop and emitting an `input` event:
2727

2828
```html
2929
<ChildComponent v-model="pageTitle" />
@@ -87,9 +87,9 @@ For convenience, we had a shorthand for this pattern with the .sync modifier:
8787
<ChildComponent :title.sync="pageTitle" />
8888
```
8989

90-
## Current Syntax
90+
## 3.x Syntax
9191

92-
In v3 `v-model` on the custom component is an equivalent of passing a `modelValue` prop and emitting an `update:modelValue` event:
92+
In 3.x `v-model` on the custom component is an equivalent of passing a `modelValue` prop and emitting an `update:modelValue` event:
9393

9494
```html
9595
<ChildComponent v-model="pageTitle" />
@@ -130,7 +130,7 @@ This also serves as a replacement to `.sync` modifier and allows us to have mult
130130

131131
### `v-model` modifiers
132132

133-
In addition to v2 hard-coded `v-model` modifiers like `.trim`, now v3 supports custom modifiers:
133+
In addition to 2.x hard-coded `v-model` modifiers like `.trim`, now 3.x supports custom modifiers:
134134

135135
```html
136136
<ChildComponent v-model.capitalize="pageTitle" />

0 commit comments

Comments
 (0)