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

fix(code-gen): support attribute binding syntax :<name>.attr #1047

Merged

Conversation

ahnpnl
Copy link
Contributor

@ahnpnl ahnpnl commented Mar 15, 2022

Summary

Added missing support for attribute binding syntax :<name>.attr. Reference https://vuejs.org/api/built-in-directives.html#v-bind

For example

<div :someProperty.attr="someString"></div>

related to #992

The other way of binding attribute

<div ^someProperty="someString"></div>

I don't know how to fix yet. When debugging, prop.type for this syntax is CompilerDOM.NodeTypes.ATTRIBUTE while the above syntax is CompilerDOM.NodeTypes.DIRECTIVE. Not sure if that is Vue SFC compiler issue or not.

IMO, since both syntaxes are equivalent, their prop.type should be the same. Probably you have more insight with Vue team about that.

Test plan

  • Pick up any projects using vue-tsc
  • Create a SFC file with attribute binding syntax :<name>.attr in HTML part
  • Run vue-tsc against that SFC file and verify if no error occurs.

@ahnpnl
Copy link
Contributor Author

ahnpnl commented Mar 15, 2022

cc @johnsoncodehk

@johnsoncodehk
Copy link
Member

I will test it later, thank for the fix!

@johnsoncodehk
Copy link
Member

LGTM! but I forgot why not just use prop.arg.loc.source instead of prop.arg.content.substring(1), will add some tests for record in future.

I don't know how to fix yet. When debugging, prop.type for this syntax is CompilerDOM.NodeTypes.ATTRIBUTE while the above syntax is CompilerDOM.NodeTypes.DIRECTIVE. Not sure if that is Vue SFC compiler issue or not.

I think this is SFC compiler issue, because ^someProperty should :someProperty.attr be same in AST in intuition.

@johnsoncodehk johnsoncodehk merged commit 02c28eb into vuejs:master Mar 15, 2022
@ahnpnl ahnpnl deleted the fix/support-attribute-binding-syntax branch March 15, 2022 12:28
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

Successfully merging this pull request may close these issues.

None yet

2 participants