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

Spread Attributes / Functional Update Syntax #10

Open
vldm opened this issue May 19, 2023 · 1 comment
Open

Spread Attributes / Functional Update Syntax #10

vldm opened this issue May 19, 2023 · 1 comment

Comments

@vldm
Copy link
Collaborator

vldm commented May 19, 2023

Original issue: stoically#27

This might already be possible with the transform_block configuration, but not exactly sure yet.

@vldm
Copy link
Collaborator Author

vldm commented Jan 16, 2024

The proposed solution:

Use syntax ...spread as in JS. But don't enforce user to use braces {}.
Expect to have spread syntax only at end of attributes declaration.

Motivation:

The syntax ... was used in rust before, as inclusive range, but for now it is kept unused.
So it is impossible to find ... in valid rust expressions, thats why using braces is not necessary.
Also, if someone want to implement spread syntax as {...foo} it will be available using transform_block feature.
The yew syntax ..foo is conflicting with our attribute parsing, and can't be supported atm.

On other hand [email protected] at its current form detect .. as part of range expression.
We using syn to parse attribute value, so using spread syntax after attribute value is imposible (example: foo="bar" ...spread is invalid)
Thats why we limit ...spread syntax to only apear at end of attributes declaration.

Examples:

Examples of some cases that would and wouldn't parse as spread syntax

❌ attribute x=y is not expected after spread syntax

<div foo="bar" ...spread x=y />

❌ spread syntax should contain 3 dots, this syntax would be treated as range expression

<div foo="bar"..spread />

✅ Spread syntax at end is valid, even if it is formatted incorrectly

<div foo="bar" some_flag...spread />
<Baz ...spread />

Limitations:

At MVP, i propose to only support one apearance of spread syntax.

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

1 participant