wip: make tests pass again

This commit is contained in:
Evan You 2021-04-08 16:33:53 -04:00
parent 18cf63ff05
commit f8e2361d83
4 changed files with 17 additions and 4 deletions

View File

@ -41,3 +41,13 @@ export function softAssertCompatEnabled(key: DeprecationTypes, ...args: any[]) {
} }
return isCompatEnabled(key) 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 }
})
}

View File

@ -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 { defineAsyncComponent } from '../apiAsyncComponent'
import { Component, ComponentOptions, FunctionalComponent } from '../component' import { Component, ComponentOptions, FunctionalComponent } from '../component'
import { isVNode } from '../vnode' import { isVNode } from '../vnode'

View File

@ -57,7 +57,7 @@ export function emit(
propsOptions: [propsOptions] propsOptions: [propsOptions]
} = instance } = instance
if (emitsOptions) { if (emitsOptions) {
if (!(event in emitsOptions)) { if (!(event in emitsOptions) && !event.startsWith('hook:')) {
if (!propsOptions || !(toHandlerKey(event) in propsOptions)) { if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
warn( warn(
`Component emitted event "${event}" but it is neither declared in ` + `Component emitted event "${event}" but it is neither declared in ` +

View File

@ -60,8 +60,11 @@ export const withKeys = (fn: Function, modifiers: string[]) => {
let globalKeyCodes: LegacyConfig['keyCodes'] let globalKeyCodes: LegacyConfig['keyCodes']
if (__COMPAT__) { if (__COMPAT__) {
if (compatUtils.isCompatEnabled(DeprecationTypes.CONFIG_KEY_CODES)) { if (compatUtils.isCompatEnabled(DeprecationTypes.CONFIG_KEY_CODES)) {
globalKeyCodes = ((getCurrentInstance()!.appContext const instance = getCurrentInstance()
.config as any) as LegacyConfig).keyCodes if (instance) {
globalKeyCodes = ((instance.appContext.config as any) as LegacyConfig)
.keyCodes
}
} }
if (__DEV__ && modifiers.some(m => /^\d+$/.test(m))) { if (__DEV__ && modifiers.some(m => /^\d+$/.test(m))) {
compatUtils.warnDeprecation(DeprecationTypes.V_ON_KEYCODE_MODIFIER) compatUtils.warnDeprecation(DeprecationTypes.V_ON_KEYCODE_MODIFIER)