]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
feat(deprecation): deprecate @vnode hooks in favor of vue: prefix
authorEvan You <yyx990803@gmail.com>
Fri, 21 Apr 2023 07:20:12 +0000 (15:20 +0800)
committerEvan You <yyx990803@gmail.com>
Fri, 21 Apr 2023 07:20:12 +0000 (15:20 +0800)
packages/compiler-core/src/errors.ts
packages/compiler-core/src/transforms/vOn.ts
packages/compiler-dom/src/errors.ts

index db7d0eb393d87b0a5363460744c5cfd5caf87d6e..9a91b91a650d23da877d3e1977367529e720f01c 100644 (file)
@@ -97,6 +97,9 @@ export const enum ErrorCodes {
   X_CACHE_HANDLER_NOT_SUPPORTED,
   X_SCOPE_ID_NOT_SUPPORTED,
 
+  // deprecations
+  DEPRECATION_VNODE_HOOKS,
+
   // Special value for higher-order compilers to pick up the last code
   // to avoid collision of error codes. This should always be kept as the last
   // item.
@@ -179,6 +182,9 @@ export const errorMessages: Record<ErrorCodes, string> = {
   [ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
   [ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED]: `"scopeId" option is only supported in module mode.`,
 
+  // deprecations
+  [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.`,
+
   // just to fulfill types
   [ErrorCodes.__EXTEND_POINT__]: ``
 }
index 9fe8b6ab61cd6f69ee34e691e97860cbcb02867c..3deee2024182063f1c3837ba40d4a74b01717475 100644 (file)
@@ -43,7 +43,11 @@ export const transformOn: DirectiveTransform = (
   if (arg.type === NodeTypes.SIMPLE_EXPRESSION) {
     if (arg.isStatic) {
       let rawName = arg.content
-      // TODO deprecate @vnodeXXX usage
+      if (__DEV__ && rawName.startsWith('vnode')) {
+        context.onWarn(
+          createCompilerError(ErrorCodes.DEPRECATION_VNODE_HOOKS, arg.loc)
+        )
+      }
       if (rawName.startsWith('vue:')) {
         rawName = `vnode-${rawName.slice(4)}`
       }
index 620d62da8223641919cb97d2afd1b1d34e2ec3fa..d129dc08d4e562754003728d6c97a45d2385591a 100644 (file)
@@ -21,7 +21,7 @@ export function createDOMCompilerError(
 }
 
 export const enum DOMErrorCodes {
-  X_V_HTML_NO_EXPRESSION = 51 /* ErrorCodes.__EXTEND_POINT__ */,
+  X_V_HTML_NO_EXPRESSION = 52 /* ErrorCodes.__EXTEND_POINT__ */,
   X_V_HTML_WITH_CHILDREN,
   X_V_TEXT_NO_EXPRESSION,
   X_V_TEXT_WITH_CHILDREN,