Skip to content

Commit 8abc754

Browse files
committed
feat(compiler): lift vnode hooks deprecation warning to error
1 parent 7f00ec2 commit 8abc754

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

packages/compiler-core/__tests__/transforms/vOn.spec.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -437,22 +437,22 @@ describe('compiler: transform v-on', () => {
437437
})
438438
})
439439

440-
// TODO remove in 3.4
441-
test('case conversion for vnode hooks', () => {
442-
const { node } = parseWithVOn(`<div v-on:vnode-mounted="onMount"/>`)
443-
expect((node.codegenNode as VNodeCall).props).toMatchObject({
444-
properties: [
445-
{
446-
key: {
447-
content: `onVnodeMounted`
448-
},
449-
value: {
450-
content: `onMount`
451-
}
440+
test('error for vnode hooks', () => {
441+
const onError = vi.fn()
442+
parseWithVOn(`<div v-on:vnode-mounted="onMount"/>`, { onError })
443+
expect(onError.mock.calls[0][0]).toMatchObject({
444+
code: ErrorCodes.X_VNODE_HOOKS,
445+
loc: {
446+
start: {
447+
line: 1,
448+
column: 11
449+
},
450+
end: {
451+
line: 1,
452+
column: 24
452453
}
453-
]
454+
}
454455
})
455-
expect('@vnode-* hooks in templates are deprecated').toHaveBeenWarned()
456456
})
457457

458458
test('vue: prefixed events', () => {

packages/compiler-core/src/errors.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export enum ErrorCodes {
9090
X_V_MODEL_ON_PROPS,
9191
X_INVALID_EXPRESSION,
9292
X_KEEP_ALIVE_INVALID_CHILDREN,
93+
X_VNODE_HOOKS,
9394

9495
// generic errors
9596
X_PREFIX_ID_NOT_SUPPORTED,
@@ -98,7 +99,6 @@ export enum ErrorCodes {
9899
X_SCOPE_ID_NOT_SUPPORTED,
99100

100101
// deprecations
101-
DEPRECATION_VNODE_HOOKS,
102102
DEPRECATION_V_IS,
103103

104104
// Special value for higher-order compilers to pick up the last code
@@ -176,6 +176,7 @@ export const errorMessages: Record<ErrorCodes, string> = {
176176
[ErrorCodes.X_V_MODEL_ON_PROPS]: `v-model cannot be used on a prop, because local prop bindings are not writable.\nUse a v-bind binding combined with a v-on listener that emits update:x event instead.`,
177177
[ErrorCodes.X_INVALID_EXPRESSION]: `Error parsing JavaScript expression: `,
178178
[ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN]: `<KeepAlive> expects exactly one child component.`,
179+
[ErrorCodes.X_VNODE_HOOKS]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
179180

180181
// generic errors
181182
[ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
@@ -184,7 +185,6 @@ export const errorMessages: Record<ErrorCodes, string> = {
184185
[ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED]: `"scopeId" option is only supported in module mode.`,
185186

186187
// deprecations
187-
[ErrorCodes.DEPRECATION_VNODE_HOOKS]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
188188
[ErrorCodes.DEPRECATION_V_IS]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
189189

190190
// just to fulfill types

packages/compiler-core/src/transforms/vOn.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ export const transformOn: DirectiveTransform = (
4444
if (arg.isStatic) {
4545
let rawName = arg.content
4646
if (__DEV__ && rawName.startsWith('vnode')) {
47-
context.onWarn(
48-
createCompilerError(ErrorCodes.DEPRECATION_VNODE_HOOKS, arg.loc)
49-
)
47+
context.onError(createCompilerError(ErrorCodes.X_VNODE_HOOKS, arg.loc))
5048
}
5149
if (rawName.startsWith('vue:')) {
5250
rawName = `vnode-${rawName.slice(4)}`

0 commit comments

Comments
 (0)