fix: allow Option<T> and &T as VNode children in html! macro#4005
Merged
Conversation
|
Visit the preview URL for this PR (updated for commit cdb6993): https://yew-rs--pr4005-fix-option-into-vnod-3dj9h7i0.web.app (expires Thu, 05 Mar 2026 07:28:01 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Benchmark - coreYew MasterPull Request |
Benchmark - SSRYew MasterDetails
Pull RequestDetails
|
Size ComparisonDetails
✅ None of the examples has changed their size significantly. |
…html! Generalize `IntoPropValue<VNode> for Option<VNode>` into a blanket `IntoPropValue<VNode> for Option<T>` where `T: IntoPropValue<VNode>`. The single-expression child path in the html! macro calls `IntoPropValue::<VNode>::into_prop_value()` directly, which only had an impl for `Option<VNode>`. This is a regression from the removal of the `ToHtml` trait, which had a blanket `Option<T: ToHtml>` impl.
67a05a7 to
2b996c2
Compare
Member
Author
|
Also adds Discovered via yew-hooks, which had to add |
Add IntoPropValue<VNode> impls for &T where T already has an impl, via
the impl_into_prop_value_via_display! and impl_into_prop_value_via_attr_value!
macros. This fixes a regression from the ToHtml removal where expressions
like {&num} or {element} (where element: &i32 from .iter()) failed as
single children of HTML elements.
99fb43a to
6331a01
Compare
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.
Description
Reported on Discord
Generalize
IntoPropValue<VNode> for Option<VNode>into a blanketIntoPropValue<VNode> for Option<T>whereT: IntoPropValue<VNode>.The single-expression child path in the html! macro calls
IntoPropValue::<VNode>::into_prop_value()directly, which only had an impl forOption<VNode>. This is a regression from the removal of theToHtmltrait, which had a blanketOption<T: ToHtml>impl.Checklist