]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: fix compat utils usage
authorEvan You <yyx990803@gmail.com>
Sat, 10 Apr 2021 03:21:13 +0000 (23:21 -0400)
committerEvan You <yyx990803@gmail.com>
Sat, 10 Apr 2021 03:21:54 +0000 (23:21 -0400)
packages/runtime-core/src/apiWatch.ts
packages/runtime-core/src/compat/deprecations.ts
packages/runtime-core/src/renderer.ts
packages/runtime-dom/src/components/Transition.ts
packages/runtime-dom/src/components/TransitionGroup.ts
packages/runtime-dom/src/directives/vOn.ts
packages/runtime-dom/src/index.ts
packages/runtime-dom/src/modules/attrs.ts

index d33adb3e35335a5702e1cfabc9a0b0e34ad9fdbb..b739ef26f053ff2d28618ce039533bed6b748054 100644 (file)
@@ -226,7 +226,7 @@ function doWatch(
       const val = baseGetter()
       if (
         isArray(val) &&
-        softAssertCompatEnabled(DeprecationTypes.WATCH_ARRAY)
+        softAssertCompatEnabled(DeprecationTypes.WATCH_ARRAY, instance)
       ) {
         traverse(val)
       }
@@ -277,7 +277,7 @@ function doWatch(
         hasChanged(newValue, oldValue) ||
         (__COMPAT__ &&
           isArray(newValue) &&
-          isCompatEnabled(DeprecationTypes.WATCH_ARRAY))
+          isCompatEnabled(DeprecationTypes.WATCH_ARRAY, instance))
       ) {
         // cleanup before running cb again
         if (cleanup) {
index 8a00ab0e4b6882548c39408bede01bba49db1dcb..e91ea9204870d2ff8ba144acaf39ec5f2137b3c3 100644 (file)
@@ -1,4 +1,4 @@
-import { hasOwn, isArray } from '@vue/shared/src'
+import { hasOwn, isArray } from '@vue/shared'
 import {
   ComponentInternalInstance,
   ComponentOptions,
index a6ad23d0ed357fcdb9a0665b7d4991d3c34f4fe4..3830258925b6de8ac44e9024c1f142cd097dd9aa 100644 (file)
@@ -443,7 +443,7 @@ function baseCreateRenderer(
   createHydrationFns?: typeof createHydrationFunctions
 ): any {
   const isHookEventCompatEnabled =
-    __COMPAT__ && isCompatEnabled(DeprecationTypes.INSTANCE_EVENT_HOOKS)
+    __COMPAT__ && isCompatEnabled(DeprecationTypes.INSTANCE_EVENT_HOOKS, null)
 
   // compile-time feature flags check
   if (__ESM_BUNDLER__ && !__TEST__) {
index 0d5681cb7ddbd37d3cbf8c7a62330410d41b1984..1121af1ebf31095b603011637c27ad61a307082f 100644 (file)
@@ -103,7 +103,7 @@ export function resolveTransitionProps(
   // legacy transition class compat
   const legacyClassEnabled =
     __COMPAT__ &&
-    compatUtils.isCompatEnabled(DeprecationTypes.TRANSITION_CLASSES)
+    compatUtils.isCompatEnabled(DeprecationTypes.TRANSITION_CLASSES, null)
   let legacyEnterFromClass: string
   let legacyAppearFromClass: string
   let legacyLeaveFromClass: string
index 02fa38f10be8de541c1bb616dfbb406cb32c4bae..50c526badd8137eb9a71d49cb94e54aa7a5028ab 100644 (file)
@@ -107,7 +107,8 @@ const TransitionGroupImpl = {
         __COMPAT__ &&
         !rawProps.tag &&
         compatUtils.softAssertCompatEnabled(
-          DeprecationTypes.TRANSITION_GROUP_ROOT
+          DeprecationTypes.TRANSITION_GROUP_ROOT,
+          instance.parent
         )
       ) {
         tag = 'span'
index 4de92f1541f710b7de119fb2763e541a3e72340a..45fc58ade70e4ba30d9a1a42d422f149d06d67fa 100644 (file)
@@ -2,7 +2,8 @@ import {
   getCurrentInstance,
   DeprecationTypes,
   LegacyConfig,
-  compatUtils
+  compatUtils,
+  ComponentInternalInstance
 } from '@vue/runtime-core'
 import { hyphenate, isArray } from '@vue/shared'
 
@@ -58,16 +59,22 @@ const keyNames: Record<string, string | string[]> = {
  */
 export const withKeys = (fn: Function, modifiers: string[]) => {
   let globalKeyCodes: LegacyConfig['keyCodes']
+  let instance: ComponentInternalInstance | null = null
   if (__COMPAT__) {
-    if (compatUtils.isCompatEnabled(DeprecationTypes.CONFIG_KEY_CODES)) {
-      const instance = getCurrentInstance()
+    instance = getCurrentInstance()
+    if (
+      compatUtils.isCompatEnabled(DeprecationTypes.CONFIG_KEY_CODES, instance)
+    ) {
       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)
+      compatUtils.warnDeprecation(
+        DeprecationTypes.V_ON_KEYCODE_MODIFIER,
+        instance
+      )
     }
   }
 
@@ -84,7 +91,10 @@ export const withKeys = (fn: Function, modifiers: string[]) => {
     if (__COMPAT__) {
       const keyCode = String(event.keyCode)
       if (
-        compatUtils.isCompatEnabled(DeprecationTypes.V_ON_KEYCODE_MODIFIER) &&
+        compatUtils.isCompatEnabled(
+          DeprecationTypes.V_ON_KEYCODE_MODIFIER,
+          instance
+        ) &&
         modifiers.some(mod => mod == keyCode)
       ) {
         return fn(event)
index 767b70074e6262f3c62c88f71d71a18a72effed9..780152aa568dff0921f8f574ea1470d3c314f57b 100644 (file)
@@ -78,7 +78,10 @@ export const createApp = ((...args) => {
         for (let i = 0; i < container.attributes.length; i++) {
           const attr = container.attributes[i]
           if (attr.name !== 'v-cloak' && /^(v-|:|@)/.test(attr.name)) {
-            compatUtils.warnDeprecation(DeprecationTypes.GLOBAL_MOUNT_CONTAINER)
+            compatUtils.warnDeprecation(
+              DeprecationTypes.GLOBAL_MOUNT_CONTAINER,
+              null
+            )
             break
           }
         }
index 975f6cbebe75b1b548cfc006a2f15d3c4a3a645f..fc3ead5266a0cd6fb146e3947e07240241b48f84 100644 (file)
@@ -54,6 +54,7 @@ export function compatCoerceAttr(
       v2CocercedValue &&
       compatUtils.softAssertCompatEnabled(
         DeprecationTypes.ATTR_ENUMERATED_COERSION,
+        null,
         key,
         value,
         v2CocercedValue
@@ -65,7 +66,11 @@ export function compatCoerceAttr(
   } else if (
     value === false &&
     !isSpecialBooleanAttr(key) &&
-    compatUtils.softAssertCompatEnabled(DeprecationTypes.ATTR_FALSE_VALUE, key)
+    compatUtils.softAssertCompatEnabled(
+      DeprecationTypes.ATTR_FALSE_VALUE,
+      null,
+      key
+    )
   ) {
     el.removeAttribute(key)
     return true