]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
feat(deprecation): deprecate v-is directive
authorEvan You <yyx990803@gmail.com>
Fri, 21 Apr 2023 07:26:01 +0000 (15:26 +0800)
committerEvan You <yyx990803@gmail.com>
Fri, 21 Apr 2023 07:30:26 +0000 (15:30 +0800)
packages/compiler-core/src/errors.ts
packages/compiler-core/src/parse.ts
packages/compiler-core/src/transforms/transformElement.ts
packages/compiler-dom/src/errors.ts
packages/compiler-ssr/src/errors.ts

index 9a91b91a650d23da877d3e1977367529e720f01c..36ab783edbe00d2175fd78252df4f50b4912bc1b 100644 (file)
@@ -99,6 +99,7 @@ export const enum ErrorCodes {
 
   // deprecations
   DEPRECATION_VNODE_HOOKS,
+  DEPRECATION_V_IS,
 
   // 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
@@ -183,7 +184,8 @@ export const errorMessages: Record<ErrorCodes, string> = {
   [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.`,
+  [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.`,
+  [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.`,
 
   // just to fulfill types
   [ErrorCodes.__EXTEND_POINT__]: ``
index 93ecf7be39936b7215b24092221722e8ed93de0c..73a1953348e841abc87aa603a28b259aee397e05 100644 (file)
@@ -687,7 +687,7 @@ function isComponent(
       }
     } else {
       // directive
-      // v-is (TODO Deprecate)
+      // v-is (TODO: remove in 3.4)
       if (p.name === 'is') {
         return true
       } else if (
index 52612edd612e6b702f86649fdf6c4aafeaec8cd3..253b6be5efa1948cd0150d141b887ae3b78b3f6d 100644 (file)
@@ -285,9 +285,14 @@ export function resolveComponentType(
     }
   }
 
-  // 1.5 v-is (TODO: Deprecate)
+  // 1.5 v-is (TODO: remove in 3.4)
   const isDir = !isExplicitDynamic && findDir(node, 'is')
   if (isDir && isDir.exp) {
+    if (__DEV__) {
+      context.onWarn(
+        createCompilerError(ErrorCodes.DEPRECATION_V_IS, isDir.loc)
+      )
+    }
     return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
       isDir.exp
     ])
index d129dc08d4e562754003728d6c97a45d2385591a..b519dbdb762221041aadd5351103b0f27e05d91e 100644 (file)
@@ -21,7 +21,7 @@ export function createDOMCompilerError(
 }
 
 export const enum DOMErrorCodes {
-  X_V_HTML_NO_EXPRESSION = 52 /* ErrorCodes.__EXTEND_POINT__ */,
+  X_V_HTML_NO_EXPRESSION = 53 /* ErrorCodes.__EXTEND_POINT__ */,
   X_V_HTML_WITH_CHILDREN,
   X_V_TEXT_NO_EXPRESSION,
   X_V_TEXT_WITH_CHILDREN,
@@ -41,7 +41,9 @@ if (__TEST__) {
   // errors out if there are collisions.
   if (DOMErrorCodes.X_V_HTML_NO_EXPRESSION < ErrorCodes.__EXTEND_POINT__) {
     throw new Error(
-      'DOMErrorCodes need to be updated to match extension point from core ErrorCodes.'
+      `DOMErrorCodes need to be updated to ${
+        ErrorCodes.__EXTEND_POINT__ + 1
+      } to match extension point from core ErrorCodes.`
     )
   }
 }
index 67622c1beb9a77471e50272518e67b9a850d8df6..e8e5a3a541dcdf8f5de0a8f73d0b9598887fc03e 100644 (file)
@@ -17,7 +17,7 @@ export function createSSRCompilerError(
 }
 
 export const enum SSRErrorCodes {
-  X_SSR_UNSAFE_ATTR_NAME = 62 /* DOMErrorCodes.__EXTEND_POINT__ */,
+  X_SSR_UNSAFE_ATTR_NAME = 65 /* DOMErrorCodes.__EXTEND_POINT__ */,
   X_SSR_NO_TELEPORT_TARGET,
   X_SSR_INVALID_AST_NODE
 }
@@ -28,7 +28,9 @@ if (__TEST__) {
   // errors out if there are collisions.
   if (SSRErrorCodes.X_SSR_UNSAFE_ATTR_NAME < DOMErrorCodes.__EXTEND_POINT__) {
     throw new Error(
-      'SSRErrorCodes need to be updated to match extension point from core DOMErrorCodes.'
+      `SSRErrorCodes need to be updated to ${
+        DOMErrorCodes.__EXTEND_POINT__ + 1
+      } to match extension point from core DOMErrorCodes.`
     )
   }
 }