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

🐛 BUG: Multiple property spreads with class don't work properly with scoped CSS #555

Open
1 task
rafal-majewski opened this issue Aug 8, 2022 · 3 comments
Assignees
Labels
- P2: has workaround Bug, but has workaround (priority)

Comments

@rafal-majewski
Copy link

rafal-majewski commented Aug 8, 2022

What version of astro are you using?

1.0.0-rc.7

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Linux

Describe the Bug

There is a problem with multiple property spreads like <div {...props1} {...props2} />. If the element is locally styled and the second props object contains a class entry then the class is not applied.

Reversing the order of props spreading works: <div {...props2} {...props1} /> produces the correct result.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/astro-multi-spread-props-problem

Participation

  • I am willing to submit a pull request for this issue.
@natemoo-re natemoo-re added - P4: important Violate documented behavior or significantly improves performance (priority) - P2: has workaround Bug, but has workaround (priority) s2-medium and removed - P4: important Violate documented behavior or significantly improves performance (priority) labels Aug 8, 2022
@natemoo-re
Copy link
Member

Thanks for opening an issue!

We are doing some compiler magic behind the scenes to make scoped classes work with spread attributes, but I don't think we considered multiple spreads. It's totally valid, we just haven't implemented it yet.

As a workaround, you can always explicitly pass class since you know where it's coming from.

@matthewp
Copy link
Contributor

matthewp commented Oct 7, 2022

Issue still exists: https://stackblitz.com/edit/astro-multi-spread-props-problem-jmpcga?file=src%2Fpages%2Findex.astro. probably a small thing to fix

@FredKSchott FredKSchott transferred this issue from withastro/astro Oct 7, 2022
@MoustaphaDev
Copy link
Member

MoustaphaDev commented Dec 19, 2023

This happens because these two spreads end up injecting two class attributes. The second class attribute is removed by the browser to correct the markup.
I'll take a look

@MoustaphaDev MoustaphaDev self-assigned this Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority)
Projects
None yet
Development

No branches or pull requests

5 participants