Skip to content

prop with no value is misleading #1644

Closed
@kamerat

Description

@kamerat

The docs specifies the following:

<!-- Including the prop with no value will imply `true`. -->
<blog-post favorited></blog-post>

In my brain this tells me to do the following:

<blog-post favorited></blog-post>
export default {
    name: 'blog-post',

    props: {
        favorited: false,
    }
}

This results in the prop favorited equals to "" == empty string. Not true

I know that in order to get this to work, one has to declare the prop of type boolean instead:

export default {
    name: 'blog-post',

    props: {
        favorited: Boolean,
    }
}

One could argue that the title of the doc snippet; "Passing a Boolean" should be enough for the end user to "know what to do". However, for people new to vue, I think this is expecting too much. 🤔

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions