Skip to content

Commit e69e0eb

Browse files
docs (#153): add breaking features section in migration (#158)
* refactor (#153): move migration introduction into folder * docs (#153): add keycodes deprecated section * docs (#153): update keycode file naming and terminology * docs: fix grammar Co-authored-by: Natalia Tepluhina <tarya.se@gmail.com> * docs: improve display Co-authored-by: Natalia Tepluhina <tarya.se@gmail.com> Co-authored-by: Natalia Tepluhina <tarya.se@gmail.com>
1 parent 65a7510 commit e69e0eb

File tree

3 files changed

+63
-3
lines changed

3 files changed

+63
-3
lines changed

src/.vuepress/config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,14 @@ const sidebar = {
8787
title: 'Migration to Vue 3',
8888
collapsable: true,
8989
children: [
90-
'migration',
90+
'migration/introduction',
9191
'migration/global-api',
9292
'migration/treeshaking',
9393
'migration/v-model',
9494
'migration/functional-components',
9595
'migration/async-components',
96-
'migration/custom-directives'
96+
'migration/custom-directives',
97+
'migration/keycode-modifiers'
9798
]
9899
},
99100
{

src/guide/migration.md renamed to src/guide/migration/introduction.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Migration
1+
# Introduction
22

33
> There's so much here! Does that mean 3.0 is completely different, I'll have to learn the basics all over again, and migrating will be practically impossible?
44
@@ -38,6 +38,8 @@ It depends on a few factors:
3838
3939
[//]: # 'TODO: still need to see where this lands'
4040

41+
## Overview
42+
4143
### New Features
4244

4345
Some of the new features to keep an eye on in Vue 3 include:
@@ -47,3 +49,9 @@ Some of the new features to keep an eye on in Vue 3 include:
4749
- Fragments
4850
- [Emits Component Option](/guide/component-custom-events.html)
4951
- `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)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# KeyCode Modifiers
2+
3+
## Overview
4+
5+
Here is a quick summary of what has changed:
6+
7+
- **BREAKING**: Using numbers, i.e. keyCodes, as `v-on` modifiers is no longer supported
8+
- **BREAKING**: `config.keyCodes` is no longer supported
9+
10+
## Previous Syntax
11+
12+
In Vue 2, `keyCodes` were supported as a way to modify a `v-on` method.
13+
14+
```html
15+
<!-- keyCode version -->
16+
<input v-on:keyup.13="submit" />
17+
18+
<!-- alias version -->
19+
<input v-on:keyup.enter="submit" />
20+
```
21+
22+
In addition, you could define your own aliases via the global `config.keyCodes` option.
23+
24+
```js
25+
Vue.config.keyCodes = {
26+
f1: 112
27+
}
28+
```
29+
30+
```html
31+
<!-- keyCode version -->
32+
<input v-on:keyup.112="showHelpText" />
33+
34+
<!-- custom alias version -->
35+
<input v-on:keyup.f1="showHelpText" />
36+
```
37+
38+
## Current Syntax
39+
40+
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.
41+
42+
```html
43+
<!-- Vue 3 Key Modifier on v-on -->
44+
<input v-on:keyup.delete="confirmDelete" />
45+
```
46+
47+
As a result, this means that `config.keyCodes` is now also deprecated and will no longer be supported.
48+
49+
## How to Migrate
50+
51+
For those using `keyCode` in their codbase, we recommend converting them to their kebab-cased named equivalents.

0 commit comments

Comments
 (0)