wip: apply compat enabled flags to currently implemented features

This commit is contained in:
Evan You
2021-04-07 15:38:04 -04:00
parent 208bef5d97
commit 1c2c77eb9f
13 changed files with 189 additions and 126 deletions

View File

@@ -57,10 +57,12 @@ const keyNames: Record<string, string | string[]> = {
* @private
*/
export const withKeys = (fn: Function, modifiers: string[]) => {
let keyCodes: LegacyConfig['keyCodes']
let globalKeyCodes: LegacyConfig['keyCodes']
if (__COMPAT__) {
keyCodes = ((getCurrentInstance()!.appContext
.config as any) as LegacyConfig).keyCodes
if (compatUtils.isCompatEnabled(DeprecationTypes.CONFIG_KEY_CODES)) {
globalKeyCodes = ((getCurrentInstance()!.appContext
.config as any) as LegacyConfig).keyCodes
}
if (__DEV__ && modifiers.some(m => /^\d+$/.test(m))) {
compatUtils.warnDeprecation(DeprecationTypes.V_ON_KEYCODE_MODIFIER)
}
@@ -78,12 +80,15 @@ export const withKeys = (fn: Function, modifiers: string[]) => {
if (__COMPAT__) {
const keyCode = String(event.keyCode)
if (modifiers.some(mod => mod == keyCode)) {
if (
compatUtils.isCompatEnabled(DeprecationTypes.V_ON_KEYCODE_MODIFIER) &&
modifiers.some(mod => mod == keyCode)
) {
return fn(event)
}
if (keyCodes) {
if (globalKeyCodes) {
for (const mod of modifiers) {
const codes = keyCodes[mod]
const codes = globalKeyCodes[mod]
if (codes) {
const matches = isArray(codes)
? codes.some(code => String(code) === keyCode)