From f01aadf2a16a7bef422eb039d7b157bef9ad32fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Exbrayat?= Date: Wed, 12 May 2021 23:47:00 +0200 Subject: [PATCH] fix(compat): enum coercion warning (#3755) --- packages/runtime-core/src/compat/compatConfig.ts | 6 +++--- packages/runtime-dom/src/modules/attrs.ts | 2 +- packages/vue-compat/README.md | 2 +- packages/vue-compat/__tests__/misc.spec.ts | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/runtime-core/src/compat/compatConfig.ts b/packages/runtime-core/src/compat/compatConfig.ts index 4e1c88f8..9ca7de5c 100644 --- a/packages/runtime-core/src/compat/compatConfig.ts +++ b/packages/runtime-core/src/compat/compatConfig.ts @@ -51,7 +51,7 @@ export const enum DeprecationTypes { CUSTOM_DIR = 'CUSTOM_DIR', ATTR_FALSE_VALUE = 'ATTR_FALSE_VALUE', - ATTR_ENUMERATED_COERSION = 'ATTR_ENUMERATED_COERSION', + ATTR_ENUMERATED_COERCION = 'ATTR_ENUMERATED_COERCION', TRANSITION_CLASSES = 'TRANSITION_CLASSES', TRANSITION_GROUP_ROOT = 'TRANSITION_GROUP_ROOT', @@ -323,7 +323,7 @@ export const deprecationData: Record = { link: `https://v3.vuejs.org/guide/migration/attribute-coercion.html` }, - [DeprecationTypes.ATTR_ENUMERATED_COERSION]: { + [DeprecationTypes.ATTR_ENUMERATED_COERCION]: { message: (name: string, value: any, coerced: string) => `Enumerated attribute "${name}" with v-bind value \`${value}\` will ` + `${ @@ -333,7 +333,7 @@ export const deprecationData: Record = { `If the usage is intended, ` + `you can disable the compat behavior and suppress this warning with:` + `\n\n configureCompat({ ${ - DeprecationTypes.ATTR_ENUMERATED_COERSION + DeprecationTypes.ATTR_ENUMERATED_COERCION }: false })\n`, link: `https://v3.vuejs.org/guide/migration/attribute-coercion.html` }, diff --git a/packages/runtime-dom/src/modules/attrs.ts b/packages/runtime-dom/src/modules/attrs.ts index 4e1621e9..ef0da543 100644 --- a/packages/runtime-dom/src/modules/attrs.ts +++ b/packages/runtime-dom/src/modules/attrs.ts @@ -57,7 +57,7 @@ export function compatCoerceAttr( if ( v2CocercedValue && compatUtils.softAssertCompatEnabled( - DeprecationTypes.ATTR_ENUMERATED_COERSION, + DeprecationTypes.ATTR_ENUMERATED_COERCION, instance, key, value, diff --git a/packages/vue-compat/README.md b/packages/vue-compat/README.md index 13091b31..2ff4a951 100644 --- a/packages/vue-compat/README.md +++ b/packages/vue-compat/README.md @@ -340,7 +340,7 @@ Features that start with `COMPILER_` are compiler-specific: if you are using the | V_ON_KEYCODE_MODIFIER | ● | `v-on` no longer supports keyCode modifiers | [link](https://v3.vuejs.org/guide/migration/keycode-modifiers.html) | | CUSTOM_DIR | ● | Custom directive hook names changed | [link](https://v3.vuejs.org/guide/migration/custom-directives.html) | | ATTR_FALSE_VALUE | ● | No longer removes attribute if binding value is boolean `false` | [link](https://v3.vuejs.org/guide/migration/attribute-coercion.html) | -| ATTR_ENUMERATED_COERSION | ● | No longer special case enumerated attributes | [link](https://v3.vuejs.org/guide/migration/attribute-coercion.html) | +| ATTR_ENUMERATED_COERCION | ● | No longer special case enumerated attributes | [link](https://v3.vuejs.org/guide/migration/attribute-coercion.html) | | TRANSITION_GROUP_ROOT | ● | `` no longer renders a root element by default | [link](https://v3.vuejs.org/guide/migration/transition-group.html) | | COMPONENT_ASYNC | ● | Async component API changed (now requires `defineAsyncComponent`) | [link](https://v3.vuejs.org/guide/migration/async-components.html) | | COMPONENT_FUNCTIONAL | ● | Functional component API changed (now must be plain functions) | [link](https://v3.vuejs.org/guide/migration/functional-components.html) | diff --git a/packages/vue-compat/__tests__/misc.spec.ts b/packages/vue-compat/__tests__/misc.spec.ts index 1986ae77..cce9b3f8 100644 --- a/packages/vue-compat/__tests__/misc.spec.ts +++ b/packages/vue-compat/__tests__/misc.spec.ts @@ -205,7 +205,7 @@ test('ATTR_FALSE_VALUE', () => { ).toHaveBeenWarned() }) -test('ATTR_ENUMERATED_COERSION', () => { +test('ATTR_ENUMERATED_COERCION', () => { const vm = new Vue({ template: `
` }).$mount() @@ -213,15 +213,15 @@ test('ATTR_ENUMERATED_COERSION', () => { expect(vm.$el.getAttribute('spellcheck')).toBe('true') expect(vm.$el.getAttribute('contenteditable')).toBe('true') expect( - (deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERSION] + (deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION] .message as Function)('draggable', null, 'false') ).toHaveBeenWarned() expect( - (deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERSION] + (deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION] .message as Function)('spellcheck', 0, 'true') ).toHaveBeenWarned() expect( - (deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERSION] + (deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION] .message as Function)('contenteditable', 'foo', 'true') ).toHaveBeenWarned() })