Skip to content

Commit 5f0394a

Browse files
committed
feat(deprecation): deprecate @vnode hooks in favor of vue: prefix
1 parent fe76224 commit 5f0394a

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

packages/compiler-core/src/errors.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ export const enum ErrorCodes {
9797
X_CACHE_HANDLER_NOT_SUPPORTED,
9898
X_SCOPE_ID_NOT_SUPPORTED,
9999

100+
// deprecations
101+
DEPRECATION_VNODE_HOOKS,
102+
100103
// Special value for higher-order compilers to pick up the last code
101104
// to avoid collision of error codes. This should always be kept as the last
102105
// item.
@@ -179,6 +182,9 @@ export const errorMessages: Record<ErrorCodes, string> = {
179182
[ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
180183
[ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED]: `"scopeId" option is only supported in module mode.`,
181184

185+
// deprecations
186+
[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.`,
187+
182188
// just to fulfill types
183189
[ErrorCodes.__EXTEND_POINT__]: ``
184190
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ export const transformOn: DirectiveTransform = (
4343
if (arg.type === NodeTypes.SIMPLE_EXPRESSION) {
4444
if (arg.isStatic) {
4545
let rawName = arg.content
46-
// TODO deprecate @vnodeXXX usage
46+
if (__DEV__ && rawName.startsWith('vnode')) {
47+
context.onWarn(
48+
createCompilerError(ErrorCodes.DEPRECATION_VNODE_HOOKS, arg.loc)
49+
)
50+
}
4751
if (rawName.startsWith('vue:')) {
4852
rawName = `vnode-${rawName.slice(4)}`
4953
}

packages/compiler-dom/src/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function createDOMCompilerError(
2121
}
2222

2323
export const enum DOMErrorCodes {
24-
X_V_HTML_NO_EXPRESSION = 51 /* ErrorCodes.__EXTEND_POINT__ */,
24+
X_V_HTML_NO_EXPRESSION = 52 /* ErrorCodes.__EXTEND_POINT__ */,
2525
X_V_HTML_WITH_CHILDREN,
2626
X_V_TEXT_NO_EXPRESSION,
2727
X_V_TEXT_WITH_CHILDREN,

0 commit comments

Comments
 (0)