From 89df185ff358a24ccfd3999863d91ed08d08ade1 Mon Sep 17 00:00:00 2001 From: XploitMonk0x01 Date: Wed, 18 Mar 2026 14:25:19 +0530 Subject: [PATCH] fix(html): support iterating &Children in html for-loops --- packages/yew-macro/tests/html_macro/for-pass.rs | 9 +++++++++ packages/yew/src/html/component/children.rs | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/yew-macro/tests/html_macro/for-pass.rs b/packages/yew-macro/tests/html_macro/for-pass.rs index d371a9d4e39..5d128eceb72 100644 --- a/packages/yew-macro/tests/html_macro/for-pass.rs +++ b/packages/yew-macro/tests/html_macro/for-pass.rs @@ -73,4 +73,13 @@ fn main() { } } + + let children = ::yew::Children::new(::std::vec![::yew::html! { {"x"} }]); + _ = ::yew::html! { + + }; } diff --git a/packages/yew/src/html/component/children.rs b/packages/yew/src/html/component/children.rs index 94205309bb5..2136cc4d718 100644 --- a/packages/yew/src/html/component/children.rs +++ b/packages/yew/src/html/component/children.rs @@ -261,6 +261,15 @@ impl IntoIterator for ChildrenRenderer { } } +impl IntoIterator for &ChildrenRenderer { + type IntoIter = std::vec::IntoIter; + type Item = T; + + fn into_iter(self) -> Self::IntoIter { + self.iter().collect::>().into_iter() + } +} + impl From> for Html { fn from(mut val: ChildrenRenderer) -> Self { if let Some(children) = val.children.as_mut() {