Inconsistent clone() requirement when passing Classes to HTML elements vs. components (#3589)#3931
Merged
WorldSEnder merged 5 commits intoyewstack:masterfrom Oct 22, 2025
Conversation
Benchmark - coreYew MasterPull Request |
Benchmark - SSRYew MasterDetails
Pull RequestDetails
|
Closed
3 tasks
|
Visit the preview URL for this PR (updated for commit 02efc44): https://yew-rs-api--pr3931-fix-classes-implicit-y7ul53kb.web.app (expires Wed, 29 Oct 2025 13:48:06 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Size ComparisonDetails
✅ None of the examples has changed their size significantly. |
adds an additional candidate to the impl block, which is fine
WorldSEnder
approved these changes
Oct 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There is an inconsistency in how the Classes type is handled between component props and standard HTML element attributes.
When passing a Classes prop to a Yew component, it can be passed directly without needing to call .clone(). However, when passing the same Classes value to an HTML element's class attribute, the compiler fails with a trait bound error, forcing the developer to explicitly call .clone().
This behavior is unintuitive and inconsistent, as one would expect the html! macro to handle both cases similarly.