wip: ref v-for compat
This commit is contained in:
@@ -20,6 +20,7 @@ export const enum CompilerDeprecationTypes {
|
||||
COMPILER_V_BIND_OBJECT_ORDER = 'COMPILER_V_BIND_OBJECT_ORDER',
|
||||
COMPILER_V_ON_NATIVE = 'COMPILER_V_ON_NATIVE',
|
||||
COMPILER_V_IF_V_FOR_PRECEDENCE = 'COMPILER_V_IF_V_FOR_PRECEDENCE',
|
||||
COMPILER_V_FOR_REF = 'COMPILER_V_FOR_REF',
|
||||
COMPILER_NATIVE_TEMPLATE = 'COMPILER_NATIVE_TEMPLATE',
|
||||
COMPILER_INLINE_TEMPLATE = 'COMPILER_INLINE_TEMPLATE',
|
||||
COMPILER_FILTERS = 'COMPILER_FILTER'
|
||||
@@ -78,6 +79,13 @@ const deprecationData: Record<CompilerDeprecationTypes, DeprecationData> = {
|
||||
link: `https://v3.vuejs.org/guide/migration/v-if-v-for.html`
|
||||
},
|
||||
|
||||
[CompilerDeprecationTypes.COMPILER_V_FOR_REF]: {
|
||||
message:
|
||||
`Ref usage on v-for no longer creates array ref values in Vue 3. ` +
|
||||
`Consider using function refs or refactor to avoid ref usage altogether.`,
|
||||
link: `https://v3.vuejs.org/guide/migration/array-refs.html`
|
||||
},
|
||||
|
||||
[CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE]: {
|
||||
message:
|
||||
`<template> with no special directives will render as a native template ` +
|
||||
|
||||
@@ -590,6 +590,25 @@ export function buildProps(
|
||||
runtimeDirectives.push(prop)
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
__COMPAT__ &&
|
||||
prop.type === NodeTypes.ATTRIBUTE &&
|
||||
prop.name === 'ref' &&
|
||||
context.scopes.vFor > 0 &&
|
||||
checkCompatEnabled(
|
||||
CompilerDeprecationTypes.COMPILER_V_FOR_REF,
|
||||
context,
|
||||
prop.loc
|
||||
)
|
||||
) {
|
||||
properties.push(
|
||||
createObjectProperty(
|
||||
createSimpleExpression('refInFor', true),
|
||||
createSimpleExpression('true', false)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
let propsExpression: PropsExpression | undefined = undefined
|
||||
|
||||
Reference in New Issue
Block a user