Skip to content

Commit 7a25cbb

Browse files
committed
wip: fix compat utils usage
1 parent 183f9b0 commit 7a25cbb

File tree

8 files changed

+32
-13
lines changed

8 files changed

+32
-13
lines changed

packages/runtime-core/src/apiWatch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ function doWatch(
226226
const val = baseGetter()
227227
if (
228228
isArray(val) &&
229-
softAssertCompatEnabled(DeprecationTypes.WATCH_ARRAY)
229+
softAssertCompatEnabled(DeprecationTypes.WATCH_ARRAY, instance)
230230
) {
231231
traverse(val)
232232
}
@@ -277,7 +277,7 @@ function doWatch(
277277
hasChanged(newValue, oldValue) ||
278278
(__COMPAT__ &&
279279
isArray(newValue) &&
280-
isCompatEnabled(DeprecationTypes.WATCH_ARRAY))
280+
isCompatEnabled(DeprecationTypes.WATCH_ARRAY, instance))
281281
) {
282282
// cleanup before running cb again
283283
if (cleanup) {

packages/runtime-core/src/compat/deprecations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { hasOwn, isArray } from '@vue/shared/src'
1+
import { hasOwn, isArray } from '@vue/shared'
22
import {
33
ComponentInternalInstance,
44
ComponentOptions,

packages/runtime-core/src/renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ function baseCreateRenderer(
443443
createHydrationFns?: typeof createHydrationFunctions
444444
): any {
445445
const isHookEventCompatEnabled =
446-
__COMPAT__ && isCompatEnabled(DeprecationTypes.INSTANCE_EVENT_HOOKS)
446+
__COMPAT__ && isCompatEnabled(DeprecationTypes.INSTANCE_EVENT_HOOKS, null)
447447

448448
// compile-time feature flags check
449449
if (__ESM_BUNDLER__ && !__TEST__) {

packages/runtime-dom/src/components/Transition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export function resolveTransitionProps(
103103
// legacy transition class compat
104104
const legacyClassEnabled =
105105
__COMPAT__ &&
106-
compatUtils.isCompatEnabled(DeprecationTypes.TRANSITION_CLASSES)
106+
compatUtils.isCompatEnabled(DeprecationTypes.TRANSITION_CLASSES, null)
107107
let legacyEnterFromClass: string
108108
let legacyAppearFromClass: string
109109
let legacyLeaveFromClass: string

packages/runtime-dom/src/components/TransitionGroup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ const TransitionGroupImpl = {
107107
__COMPAT__ &&
108108
!rawProps.tag &&
109109
compatUtils.softAssertCompatEnabled(
110-
DeprecationTypes.TRANSITION_GROUP_ROOT
110+
DeprecationTypes.TRANSITION_GROUP_ROOT,
111+
instance.parent
111112
)
112113
) {
113114
tag = 'span'

packages/runtime-dom/src/directives/vOn.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {
22
getCurrentInstance,
33
DeprecationTypes,
44
LegacyConfig,
5-
compatUtils
5+
compatUtils,
6+
ComponentInternalInstance
67
} from '@vue/runtime-core'
78
import { hyphenate, isArray } from '@vue/shared'
89

@@ -58,16 +59,22 @@ const keyNames: Record<string, string | string[]> = {
5859
*/
5960
export const withKeys = (fn: Function, modifiers: string[]) => {
6061
let globalKeyCodes: LegacyConfig['keyCodes']
62+
let instance: ComponentInternalInstance | null = null
6163
if (__COMPAT__) {
62-
if (compatUtils.isCompatEnabled(DeprecationTypes.CONFIG_KEY_CODES)) {
63-
const instance = getCurrentInstance()
64+
instance = getCurrentInstance()
65+
if (
66+
compatUtils.isCompatEnabled(DeprecationTypes.CONFIG_KEY_CODES, instance)
67+
) {
6468
if (instance) {
6569
globalKeyCodes = ((instance.appContext.config as any) as LegacyConfig)
6670
.keyCodes
6771
}
6872
}
6973
if (__DEV__ && modifiers.some(m => /^\d+$/.test(m))) {
70-
compatUtils.warnDeprecation(DeprecationTypes.V_ON_KEYCODE_MODIFIER)
74+
compatUtils.warnDeprecation(
75+
DeprecationTypes.V_ON_KEYCODE_MODIFIER,
76+
instance
77+
)
7178
}
7279
}
7380

@@ -84,7 +91,10 @@ export const withKeys = (fn: Function, modifiers: string[]) => {
8491
if (__COMPAT__) {
8592
const keyCode = String(event.keyCode)
8693
if (
87-
compatUtils.isCompatEnabled(DeprecationTypes.V_ON_KEYCODE_MODIFIER) &&
94+
compatUtils.isCompatEnabled(
95+
DeprecationTypes.V_ON_KEYCODE_MODIFIER,
96+
instance
97+
) &&
8898
modifiers.some(mod => mod == keyCode)
8999
) {
90100
return fn(event)

packages/runtime-dom/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ export const createApp = ((...args) => {
7878
for (let i = 0; i < container.attributes.length; i++) {
7979
const attr = container.attributes[i]
8080
if (attr.name !== 'v-cloak' && /^(v-|:|@)/.test(attr.name)) {
81-
compatUtils.warnDeprecation(DeprecationTypes.GLOBAL_MOUNT_CONTAINER)
81+
compatUtils.warnDeprecation(
82+
DeprecationTypes.GLOBAL_MOUNT_CONTAINER,
83+
null
84+
)
8285
break
8386
}
8487
}

packages/runtime-dom/src/modules/attrs.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export function compatCoerceAttr(
5454
v2CocercedValue &&
5555
compatUtils.softAssertCompatEnabled(
5656
DeprecationTypes.ATTR_ENUMERATED_COERSION,
57+
null,
5758
key,
5859
value,
5960
v2CocercedValue
@@ -65,7 +66,11 @@ export function compatCoerceAttr(
6566
} else if (
6667
value === false &&
6768
!isSpecialBooleanAttr(key) &&
68-
compatUtils.softAssertCompatEnabled(DeprecationTypes.ATTR_FALSE_VALUE, key)
69+
compatUtils.softAssertCompatEnabled(
70+
DeprecationTypes.ATTR_FALSE_VALUE,
71+
null,
72+
key
73+
)
6974
) {
7075
el.removeAttribute(key)
7176
return true

0 commit comments

Comments
 (0)