Skip to content

Commit bbd8301

Browse files
committed
feat(deprecation): deprecate v-is directive
1 parent 5f0394a commit bbd8301

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

packages/compiler-core/src/errors.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export const enum ErrorCodes {
9999

100100
// deprecations
101101
DEPRECATION_VNODE_HOOKS,
102+
DEPRECATION_V_IS,
102103

103104
// Special value for higher-order compilers to pick up the last code
104105
// to avoid collision of error codes. This should always be kept as the last
@@ -183,7 +184,8 @@ export const errorMessages: Record<ErrorCodes, string> = {
183184
[ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED]: `"scopeId" option is only supported in module mode.`,
184185

185186
// 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+
[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.`,
188+
[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.`,
187189

188190
// just to fulfill types
189191
[ErrorCodes.__EXTEND_POINT__]: ``

packages/compiler-core/src/parse.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ function isComponent(
687687
}
688688
} else {
689689
// directive
690-
// v-is (TODO Deprecate)
690+
// v-is (TODO: remove in 3.4)
691691
if (p.name === 'is') {
692692
return true
693693
} else if (

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,14 @@ export function resolveComponentType(
285285
}
286286
}
287287

288-
// 1.5 v-is (TODO: Deprecate)
288+
// 1.5 v-is (TODO: remove in 3.4)
289289
const isDir = !isExplicitDynamic && findDir(node, 'is')
290290
if (isDir && isDir.exp) {
291+
if (__DEV__) {
292+
context.onWarn(
293+
createCompilerError(ErrorCodes.DEPRECATION_V_IS, isDir.loc)
294+
)
295+
}
291296
return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
292297
isDir.exp
293298
])

packages/compiler-dom/src/errors.ts

+4-2
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 = 52 /* ErrorCodes.__EXTEND_POINT__ */,
24+
X_V_HTML_NO_EXPRESSION = 53 /* ErrorCodes.__EXTEND_POINT__ */,
2525
X_V_HTML_WITH_CHILDREN,
2626
X_V_TEXT_NO_EXPRESSION,
2727
X_V_TEXT_WITH_CHILDREN,
@@ -41,7 +41,9 @@ if (__TEST__) {
4141
// errors out if there are collisions.
4242
if (DOMErrorCodes.X_V_HTML_NO_EXPRESSION < ErrorCodes.__EXTEND_POINT__) {
4343
throw new Error(
44-
'DOMErrorCodes need to be updated to match extension point from core ErrorCodes.'
44+
`DOMErrorCodes need to be updated to ${
45+
ErrorCodes.__EXTEND_POINT__ + 1
46+
} to match extension point from core ErrorCodes.`
4547
)
4648
}
4749
}

packages/compiler-ssr/src/errors.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function createSSRCompilerError(
1717
}
1818

1919
export const enum SSRErrorCodes {
20-
X_SSR_UNSAFE_ATTR_NAME = 62 /* DOMErrorCodes.__EXTEND_POINT__ */,
20+
X_SSR_UNSAFE_ATTR_NAME = 65 /* DOMErrorCodes.__EXTEND_POINT__ */,
2121
X_SSR_NO_TELEPORT_TARGET,
2222
X_SSR_INVALID_AST_NODE
2323
}
@@ -28,7 +28,9 @@ if (__TEST__) {
2828
// errors out if there are collisions.
2929
if (SSRErrorCodes.X_SSR_UNSAFE_ATTR_NAME < DOMErrorCodes.__EXTEND_POINT__) {
3030
throw new Error(
31-
'SSRErrorCodes need to be updated to match extension point from core DOMErrorCodes.'
31+
`SSRErrorCodes need to be updated to ${
32+
DOMErrorCodes.__EXTEND_POINT__ + 1
33+
} to match extension point from core DOMErrorCodes.`
3234
)
3335
}
3436
}

0 commit comments

Comments
 (0)