]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: config.ignoredElements compat
authorEvan You <yyx990803@gmail.com>
Tue, 6 Apr 2021 14:02:46 +0000 (10:02 -0400)
committerEvan You <yyx990803@gmail.com>
Wed, 7 Apr 2021 20:19:24 +0000 (16:19 -0400)
packages/runtime-core/src/apiCreateApp.ts
packages/runtime-core/src/compat/deprecations.ts
packages/runtime-core/src/compat/global.ts
packages/runtime-core/src/compat/globalConfig.ts [new file with mode: 0644]

index 28eb0847d84023807351069b91dd8db4dc94c6d7..ed1971cbb2b651157a5a595f03749c8daf29a7d5 100644 (file)
@@ -15,7 +15,8 @@ import { RootHydrateFunction } from './hydration'
 import { devtoolsInitApp, devtoolsUnmountApp } from './devtools'
 import { isFunction, NO, isObject } from '@vue/shared'
 import { version } from '.'
-import { installCompatMount, installLegacyConfigTraps } from './compat/global'
+import { installCompatMount } from './compat/global'
+import { installLegacyConfigTraps } from './compat/globalConfig'
 
 export interface App<HostElement = any> {
   version: string
index 76a6d358a1568248739dd758ee23d6d1f8f493c0..5ba5d185a9f0288f884e9c2f2a898da08844f32f 100644 (file)
@@ -149,6 +149,6 @@ export function warnDeprecation(key: DeprecationTypes, ...args: any[]) {
   warn(
     `[DEPRECATION] ${
       typeof message === 'function' ? message(...args) : message
-    }${link ? `\nFor more details, see ${link}` : ``}`
+    }${link ? `\n  Details: ${link}` : ``}`
   )
 }
index aa59de6e741bd41e1d0049b0723557e8950f9c94..5f09239caddfdec146933d65537de70ba104f1ab 100644 (file)
@@ -27,6 +27,7 @@ import { Directive } from '../directives'
 import { nextTick } from '../scheduler'
 import { warnDeprecation, DeprecationTypes } from './deprecations'
 import { version } from '..'
+import { LegacyConfig } from './globalConfig'
 
 /**
  * @deprecated the default `Vue` export has been removed in Vue 3. The type for
@@ -73,34 +74,6 @@ export type CompatVue = Pick<App, 'version' | 'component' | 'directive'> & {
   filter(name: string, arg: any): null
 }
 
-// legacy config warnings
-export type LegacyConfig = {
-  /**
-   * @deprecated `config.silent` option has been removed
-   */
-  silent?: boolean
-  /**
-   * @deprecated use __VUE_PROD_DEVTOOLS__ compile-time feature flag instead
-   * https://github.com/vuejs/vue-next/tree/master/packages/vue#bundler-build-feature-flags
-   */
-  devtools?: boolean
-  /**
-   * @deprecated use `config.isCustomElement` instead
-   * https://v3.vuejs.org/guide/migration/global-api.html#config-ignoredelements-is-now-config-iscustomelement
-   */
-  ignoredElements?: (string | RegExp)[]
-  /**
-   * @deprecated
-   * https://v3.vuejs.org/guide/migration/keycode-modifiers.html
-   */
-  keyCodes?: Record<string, number | number[]>
-  /**
-   * @deprecated
-   * https://v3.vuejs.org/guide/migration/global-api.html#config-productiontip-removed
-   */
-  productionTip?: boolean
-}
-
 export let isCopyingConfig = false
 
 // Legacy global Vue constructor
@@ -362,30 +335,3 @@ export function installCompatMount(
     return instance.proxy!
   }
 }
-
-// dev only
-export function installLegacyConfigTraps(config: AppConfig) {
-  const legacyConfigOptions: Record<string, DeprecationTypes> = {
-    silent: DeprecationTypes.CONFIG_SILENT,
-    devtools: DeprecationTypes.CONFIG_DEVTOOLS,
-    ignoredElements: DeprecationTypes.CONFIG_IGNORED_ELEMENTS,
-    keyCodes: DeprecationTypes.CONFIG_KEY_CODES,
-    productionTip: DeprecationTypes.CONFIG_PRODUCTION_TIP
-  }
-
-  Object.keys(legacyConfigOptions).forEach(key => {
-    let val = (config as any)[key]
-    Object.defineProperty(config, key, {
-      enumerable: true,
-      get() {
-        return val
-      },
-      set(newVal) {
-        if (!isCopyingConfig) {
-          warnDeprecation(legacyConfigOptions[key])
-        }
-        val = newVal
-      }
-    })
-  })
-}
diff --git a/packages/runtime-core/src/compat/globalConfig.ts b/packages/runtime-core/src/compat/globalConfig.ts
new file mode 100644 (file)
index 0000000..734ffbb
--- /dev/null
@@ -0,0 +1,69 @@
+import { isArray, isString } from '@vue/shared'
+import { AppConfig } from '../apiCreateApp'
+import { isRuntimeOnly } from '../component'
+import { DeprecationTypes, warnDeprecation } from './deprecations'
+import { isCopyingConfig } from './global'
+
+// legacy config warnings
+export type LegacyConfig = {
+  /**
+   * @deprecated `config.silent` option has been removed
+   */
+  silent?: boolean
+  /**
+   * @deprecated use __VUE_PROD_DEVTOOLS__ compile-time feature flag instead
+   * https://github.com/vuejs/vue-next/tree/master/packages/vue#bundler-build-feature-flags
+   */
+  devtools?: boolean
+  /**
+   * @deprecated use `config.isCustomElement` instead
+   * https://v3.vuejs.org/guide/migration/global-api.html#config-ignoredelements-is-now-config-iscustomelement
+   */
+  ignoredElements?: (string | RegExp)[]
+  /**
+   * @deprecated
+   * https://v3.vuejs.org/guide/migration/keycode-modifiers.html
+   */
+  keyCodes?: Record<string, number | number[]>
+  /**
+   * @deprecated
+   * https://v3.vuejs.org/guide/migration/global-api.html#config-productiontip-removed
+   */
+  productionTip?: boolean
+}
+
+// dev only
+export function installLegacyConfigTraps(config: AppConfig) {
+  const legacyConfigOptions: Record<string, DeprecationTypes> = {
+    silent: DeprecationTypes.CONFIG_SILENT,
+    devtools: DeprecationTypes.CONFIG_DEVTOOLS,
+    ignoredElements: DeprecationTypes.CONFIG_IGNORED_ELEMENTS,
+    keyCodes: DeprecationTypes.CONFIG_KEY_CODES,
+    productionTip: DeprecationTypes.CONFIG_PRODUCTION_TIP
+  }
+
+  Object.keys(legacyConfigOptions).forEach(key => {
+    let val = (config as any)[key]
+    Object.defineProperty(config, key, {
+      enumerable: true,
+      get() {
+        return val
+      },
+      set(newVal) {
+        if (!isCopyingConfig) {
+          warnDeprecation(legacyConfigOptions[key])
+        }
+        val = newVal
+
+        // compat for runtime ignoredElements -> isCustomElement
+        if (key === 'ignoredElements' && !isRuntimeOnly() && isArray(newVal)) {
+          config.isCustomElement = tag => {
+            return newVal.some(
+              val => (isString(val) ? val === tag : val.test(tag))
+            )
+          }
+        }
+      }
+    })
+  })
+}