wip: compiler should default to v3 behavior
This commit is contained in:
parent
3528ced0b4
commit
c5c304af14
@ -306,6 +306,7 @@ describe('compiler: v-if', () => {
|
|||||||
code: ErrorCodes.X_V_IF_SAME_KEY
|
code: ErrorCodes.X_V_IF_SAME_KEY
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
expect('unnecessary key usage on v-if').toHaveBeenWarned()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -96,13 +96,18 @@ const deprecationData: Record<CompilerDeprecationTypes, DeprecationData> = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getCompatValue(
|
function getCompatValue(
|
||||||
key: CompilerDeprecationTypes,
|
key: CompilerDeprecationTypes | 'MODE',
|
||||||
context: ParserContext | TransformContext
|
context: ParserContext | TransformContext
|
||||||
) {
|
) {
|
||||||
const config = (context as ParserContext).options
|
const config = (context as ParserContext).options
|
||||||
? (context as ParserContext).options.compatConfig
|
? (context as ParserContext).options.compatConfig
|
||||||
: (context as TransformContext).compatConfig
|
: (context as TransformContext).compatConfig
|
||||||
return config && config[key]
|
const value = config && config[key]
|
||||||
|
if (key === 'MODE') {
|
||||||
|
return value || 3 // compiler defaults to v3 behavior
|
||||||
|
} else {
|
||||||
|
return value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function checkCompatEnabled(
|
export function checkCompatEnabled(
|
||||||
@ -111,9 +116,11 @@ export function checkCompatEnabled(
|
|||||||
loc: SourceLocation | null,
|
loc: SourceLocation | null,
|
||||||
...args: any[]
|
...args: any[]
|
||||||
): boolean {
|
): boolean {
|
||||||
|
const mode = getCompatValue('MODE', context)
|
||||||
const value = getCompatValue(key, context)
|
const value = getCompatValue(key, context)
|
||||||
// during tests, only enable when value is explicitly true
|
// in v3 mode, only enable if explicitly set to true
|
||||||
const enabled = __TEST__ ? value === true : value !== false
|
// otherwise enable for any non-false value
|
||||||
|
const enabled = mode === 3 ? value === true : value !== false
|
||||||
if (__DEV__ && enabled) {
|
if (__DEV__ && enabled) {
|
||||||
warnDeprecation(key, context, loc, ...args)
|
warnDeprecation(key, context, loc, ...args)
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ export function defaultOnError(error: CompilerError) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function defaultOnWarn(msg: CompilerError) {
|
export function defaultOnWarn(msg: CompilerError) {
|
||||||
__DEV__ && console.warn(`[Vue warn]`, msg.message)
|
__DEV__ && console.warn(`[Vue warn] ${msg.message}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createCompilerError<T extends number>(
|
export function createCompilerError<T extends number>(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user