Skip to content

fix(compat): enum coercion warning #3755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/runtime-core/src/compat/compatConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -323,7 +323,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
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 ` +
`${
Expand All @@ -333,7 +333,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
`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`
},
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-dom/src/modules/attrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function compatCoerceAttr(
if (
v2CocercedValue &&
compatUtils.softAssertCompatEnabled(
DeprecationTypes.ATTR_ENUMERATED_COERSION,
DeprecationTypes.ATTR_ENUMERATED_COERCION,
instance,
key,
value,
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-compat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,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 | ● | `<transition-group>` 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) |
Expand Down
8 changes: 4 additions & 4 deletions packages/vue-compat/__tests__/misc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,23 +205,23 @@ test('ATTR_FALSE_VALUE', () => {
).toHaveBeenWarned()
})

test('ATTR_ENUMERATED_COERSION', () => {
test('ATTR_ENUMERATED_COERCION', () => {
const vm = new Vue({
template: `<div :draggable="null" :spellcheck="0" contenteditable="foo" />`
}).$mount()
expect(vm.$el.getAttribute('draggable')).toBe('false')
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()
})