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

Props spreading causes an infinite loop #1843

Closed
1 of 3 tasks
atty303 opened this issue Jan 18, 2024 · 2 comments · Fixed by #1858
Closed
1 of 3 tasks

Props spreading causes an infinite loop #1843

atty303 opened this issue Jan 18, 2024 · 2 comments · Fixed by #1858
Labels
bug Something isn't working core relating to the core implementation of the virtualdom

Comments

@atty303
Copy link
Contributor

atty303 commented Jan 18, 2024

Problem

match (left_iter.peek(), right_iter.peek()) {
(Some(left), Some(right)) => {
// check which name is greater
match left.name.cmp(right.name) {
std::cmp::Ordering::Less => self.remove_attribute(
left.name,
left.namespace,
mounted_id,
),
std::cmp::Ordering::Greater => self.write_attribute(
right_template,
right,
idx,
mounted_id,
),
std::cmp::Ordering::Equal => {
self.diff_attribute(left, right, mounted_id)
}
}
}

It appears that the iterator is not consumed when it enters this case.
I tried calling left_iter.next() right_iter.next() and the infinite loop was resolved.
Is this the right way to fix it?

Environment:

  • Dioxus version: master
  • Rust version: 1.75.0]
  • OS info: Windows
  • App platform: web

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution, but I don't know how to test it.
  • I don't have time to fix this right now, but maybe later
@ealmloff
Copy link
Member

Yes, the item should be consumed in each of those branches.

You can test the fix by trying to diff two spread attributes with a different number of attributes (both small -> large and large -> small)

@ealmloff ealmloff added bug Something isn't working core relating to the core implementation of the virtualdom labels Jan 18, 2024
egegungordu added a commit to egegungordu/dioxus that referenced this issue Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core relating to the core implementation of the virtualdom
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants