Skip to content
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

Yet another prop and event handler shorthand #12599

Closed
zsakowitz opened this issue Jul 2, 2022 · 1 comment
Closed

Yet another prop and event handler shorthand #12599

zsakowitz opened this issue Jul 2, 2022 · 1 comment

Comments

@zsakowitz
Copy link

zsakowitz commented Jul 2, 2022

What problem does this feature solve?

I commonly need to pass props down from one component to a child component. For example, I recently wanted to pass a disabled prop to a subcomponent called . I feel that writing

<Button :disabled="disabled" />

feels too cluttered. When people have suggested this elsewhere, some recommend using

<Button v-bind="{ disabled "} />

The problem with this approach is that an unnecessary v-bind is introduced which could be omitted.

What does the proposed API look like?

I understand that the shorthand syntax

<Button :disabled @click />

has been scrapped many, many, many, many, many, many, many (holy moly, the list just keeps going) times in the past, but I propose a new syntax similar to Svelte's prop shorthands.

<Button {disabled} {@click} />

The above syntaxes are similar to the existing object shorthand in JavaScript, so it would feel familiar to new developers. Furthermore, it would not be a breaking change (compared to #5835) since Vue props rarely use curly braces in their names.

If possible, I would also wish for a shorthand such as

<Button {disabled, @click} />

to be allowed, but I realize that the space in the attribute name prevents it from being valid HTML.

@posva
Copy link
Member

posva commented Jul 2, 2022

This should go in the vue/rfcs repo. Check there if there is an already open proposal.

@posva posva closed this as completed Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants