From f8e2361d831208708ba55be05e4d7a96e2f9480a Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 8 Apr 2021 16:33:53 -0400 Subject: [PATCH] wip: make tests pass again --- packages/runtime-core/src/compat/compatConfig.ts | 10 ++++++++++ packages/runtime-core/src/compat/component.ts | 2 +- packages/runtime-core/src/componentEmits.ts | 2 +- packages/runtime-dom/src/directives/vOn.ts | 7 +++++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/runtime-core/src/compat/compatConfig.ts b/packages/runtime-core/src/compat/compatConfig.ts index 201bc14a..d8508853 100644 --- a/packages/runtime-core/src/compat/compatConfig.ts +++ b/packages/runtime-core/src/compat/compatConfig.ts @@ -41,3 +41,13 @@ export function softAssertCompatEnabled(key: DeprecationTypes, ...args: any[]) { } return isCompatEnabled(key) } + +// disable features that conflict with v3 behavior +if (__TEST__) { + configureCompat({ + COMPONENT_ASYNC: { enabled: false }, + COMPONENT_FUNCTIONAL: { enabled: false }, + WATCH_ARRAY: { enabled: false }, + INSTANCE_ATTRS_CLASS_STYLE: { enabled: false } + }) +} diff --git a/packages/runtime-core/src/compat/component.ts b/packages/runtime-core/src/compat/component.ts index ca15a657..6168c3e7 100644 --- a/packages/runtime-core/src/compat/component.ts +++ b/packages/runtime-core/src/compat/component.ts @@ -1,4 +1,4 @@ -import { isArray, isFunction, isObject, isPromise } from '@vue/shared/src' +import { isArray, isFunction, isObject, isPromise } from '@vue/shared' import { defineAsyncComponent } from '../apiAsyncComponent' import { Component, ComponentOptions, FunctionalComponent } from '../component' import { isVNode } from '../vnode' diff --git a/packages/runtime-core/src/componentEmits.ts b/packages/runtime-core/src/componentEmits.ts index 73cd2b70..a4ffdf89 100644 --- a/packages/runtime-core/src/componentEmits.ts +++ b/packages/runtime-core/src/componentEmits.ts @@ -57,7 +57,7 @@ export function emit( propsOptions: [propsOptions] } = instance if (emitsOptions) { - if (!(event in emitsOptions)) { + if (!(event in emitsOptions) && !event.startsWith('hook:')) { if (!propsOptions || !(toHandlerKey(event) in propsOptions)) { warn( `Component emitted event "${event}" but it is neither declared in ` + diff --git a/packages/runtime-dom/src/directives/vOn.ts b/packages/runtime-dom/src/directives/vOn.ts index 665214b7..4de92f15 100644 --- a/packages/runtime-dom/src/directives/vOn.ts +++ b/packages/runtime-dom/src/directives/vOn.ts @@ -60,8 +60,11 @@ export const withKeys = (fn: Function, modifiers: string[]) => { let globalKeyCodes: LegacyConfig['keyCodes'] if (__COMPAT__) { if (compatUtils.isCompatEnabled(DeprecationTypes.CONFIG_KEY_CODES)) { - globalKeyCodes = ((getCurrentInstance()!.appContext - .config as any) as LegacyConfig).keyCodes + const instance = getCurrentInstance() + if (instance) { + globalKeyCodes = ((instance.appContext.config as any) as LegacyConfig) + .keyCodes + } } if (__DEV__ && modifiers.some(m => /^\d+$/.test(m))) { compatUtils.warnDeprecation(DeprecationTypes.V_ON_KEYCODE_MODIFIER)