Skip to content

fix(html): support iterating & Children in html for-loops#4074

Open
XploitMonk0x01 wants to merge 1 commit intoyewstack:masterfrom
XploitMonk0x01:fix/4073-html-for-ref-children
Open

fix(html): support iterating & Children in html for-loops#4074
XploitMonk0x01 wants to merge 1 commit intoyewstack:masterfrom
XploitMonk0x01:fix/4073-html-for-ref-children

Conversation

@XploitMonk0x01
Copy link

  • Added reference iteration support for Children so html for-loops can work with &children style.
  • Added a compile-pass macro test that uses for child in &children.

@github-actions
Copy link

Visit the preview URL for this PR (updated for commit 89df185):

https://yew-rs-api--pr4074-fix-4073-html-for-re-rngw6dvr.web.app

(expires Wed, 25 Mar 2026 10:02:08 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@github-actions
Copy link

Benchmark - core

Yew Master

vnode           fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ vnode_clone  2.174 ns      │ 3.425 ns      │ 2.177 ns      │ 2.226 ns      │ 100     │ 1000000000

Pull Request

vnode           fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ vnode_clone  2.175 ns      │ 4.265 ns      │ 2.18 ns       │ 2.51 ns       │ 100     │ 1000000000

@github-actions
Copy link

Size Comparison

Details
examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 101.095 101.095 0 0.000%
boids 168.882 168.882 0 0.000%
communication_child_to_parent 94.509 94.509 0 0.000%
communication_grandchild_with_grandparent 106.351 106.351 0 0.000%
communication_grandparent_to_grandchild 102.692 102.692 0 0.000%
communication_parent_to_child 91.921 91.921 0 0.000%
contexts 106.411 106.411 0 0.000%
counter 87.231 87.231 0 0.000%
counter_functional 89.269 89.269 0 0.000%
dyn_create_destroy_apps 91.146 91.146 0 0.000%
file_upload 100.326 100.326 0 0.000%
function_delayed_input 95.241 95.241 0 0.000%
function_memory_game 174.099 174.099 0 0.000%
function_router 395.915 395.915 0 0.000%
function_todomvc 165.385 165.385 0 0.000%
futures 235.984 235.984 0 0.000%
game_of_life 105.532 105.532 0 0.000%
immutable 260.494 260.494 0 0.000%
inner_html 81.774 81.774 0 0.000%
js_callback 110.397 110.397 0 0.000%
keyed_list 180.710 180.710 0 0.000%
mount_point 85.147 85.147 0 0.000%
nested_list 114.091 114.091 0 0.000%
node_refs 92.521 92.521 0 0.000%
password_strength 1719.354 1719.354 0 0.000%
portals 93.992 93.992 0 0.000%
router 366.558 366.558 0 0.000%
suspense 114.395 114.395 0 0.000%
timer 89.369 89.369 0 0.000%
timer_functional 99.803 99.803 0 0.000%
todomvc 143.096 143.096 0 0.000%
two_apps 87.145 87.145 0 0.000%
web_worker_fib 137.045 137.045 0 0.000%
web_worker_prime 188.227 188.227 0 0.000%
webgl 83.920 83.920 0 0.000%

✅ None of the examples has changed their size significantly.

@github-actions
Copy link

Benchmark - SSR

Yew Master

Details
Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 291.234 292.015 291.548 0.255
Hello World 10 473.771 495.915 479.111 6.331
Function Router 10 31960.081 32593.986 32321.347 240.890
Concurrent Task 10 1005.929 1007.770 1006.942 0.613
Many Providers 10 1050.356 1096.014 1069.084 16.141

Pull Request

Details
Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 291.273 291.666 291.434 0.113
Hello World 10 496.271 501.414 498.367 1.902
Function Router 10 31439.460 32315.924 31901.678 294.461
Concurrent Task 10 1006.397 1007.769 1007.176 0.567
Many Providers 10 1080.004 1142.325 1100.705 18.303

Copy link
Member

@Madoshakalaka Madoshakalaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you fix the syntax error and reference the issue.

type Item = T;

fn into_iter(self) -> Self::IntoIter {
self.iter().collect::<Vec<_>>().into_iter()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could return just self.iter() and avoid the clone of the whole Vec with more precise types, I believe.

I do note that with some self-referential tricks, the above impl for ChildrenRenderer<T> could do the same, clone just the Rc instead of the whole Vec. Being able to just take a reference to the contained Vec without carrying around the owner should be a lot simpler in this case though.

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

Successfully merging this pull request may close these issues.

3 participants