Skip to content

v-model on checkboxes no longer works with truthy/falsy values #5775

Open
@marcovdb

Description

@marcovdb

Version

3.2.33

Reproduction link

sfc.vuejs.org/

Steps to reproduce

  1. Bind a non-boolean, truthy value to a checkbox using v-model
  2. Observe that the checkbox is, in fact, not checked

What is expected?

v-model, at least in Vue 2, used to work fine with checkboxes using truthy and falsy values instead of strict boolean values. So I would expect this behavior to continue in Vue 3, especially since this isn't listed as a breaking change, which it definitely is.

What is actually happening?

Vue only checks the checkbox if the corresponding v-model has the boolean value of true. It ignores all else.


Case in point, I am working with an API that returns boolean-like values as 0/1 instead of true/false, for reasons of SQL. This was never an issue with Vue 2. I am aware of the true-value and false-value attributes but that shouldn't be necessary... right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 bugSomething isn't workinghas workaroundA workaround has been found to avoid the problemneed guidanceThe approach/solution in the PR is unclear and requires guidance from maintainer to proceed further.scope: v-model

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions