-
Notifications
You must be signed in to change notification settings - Fork 154
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
Fix reconcile_fragments wrongly ordering nodes #570
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #570 +/- ##
==========================================
+ Coverage 60.78% 60.79% +0.01%
==========================================
Files 56 56
Lines 9340 9349 +9
==========================================
+ Hits 5677 5684 +7
- Misses 3663 3665 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
I think the extra assets make sense but I'm not sure the new logic does. In any case, it seems like some tests for |
Oh wait, I think the reason why the tests are failing is because of the new assert. It's because the fragment doesn't necessarily span the whole element. It's possible to have something like: div {
"before"
(fragment)
"after"
} where the Perhaps the assert can be fixed by slicing the |
…s; add in a debug assertion that would have caught this
eda05d5
to
5162225
Compare
Apologies, oversight on my part. Fixed and now passing CI, bar clippy on untouched code. I'm afraid I didn't really grok the logic here so I don't have much confidence in my fix, nor the fn as a whole? I'd trust a simple fuzzer plus the assertions. Will add that if I have any more issues here! My testcase was fragment |
Thanks for the test case! I'll experiment a bit and let you know (hopefully soon). Edit: Also don't worry about clippy. The errors are lints from a new rust version which I haven't had time to fix yet haha! |
Sorry for taking so long to get back to you. It seems like your testcase already passes on master without your changes. Could you please verify this on your side? Once again, really sorry for not replying earlier. |
For reference, here is the test case which already passes on master: #[wasm_bindgen_test]
fn regression_570() {
let nodes = [
DomNode::text_node("0".into()),
DomNode::text_node("1".into()),
DomNode::text_node("2".into()),
DomNode::text_node("3".into()),
DomNode::text_node("4".into()),
DomNode::text_node("5".into()),
];
let parent = DomNode::element::<html::div>();
for node in &nodes[..4] {
parent.append_child(node);
}
assert_text_content!(parent.to_web_sys(), "0123");
reconcile_fragments(
&parent,
&mut [
nodes[0].clone(),
nodes[1].clone(),
nodes[2].clone(),
nodes[3].clone(),
],
&[
nodes[0].clone(),
nodes[4].clone(),
nodes[2].clone(),
nodes[5].clone(),
],
);
assert_text_content!(parent.to_web_sys(), "0425");
} If this is not what you had in mind, please let me know. |
Thanks for the response @lukechu10. It's going to be a little while before we can update from the version we're pinned to to However I'm quite sure this bug isn't fixed on |
Note that I've already merged the latest changes on master onto this branch. There aren't any merge conflicts right now. |
Ah ok I understand now. Also note that you can replace all the places where |
Closing because of inactivity. If this still persists after #626, please open a new issue. |
I was seeing
reconcile_fragments
leave nodes in the wrong order. Thedebug_assert_eq
at the bottom of my patch was failing.This patch fixes the issue I was seeing.. but I'm still a bit suspicious of this code. Hopefully the debug assert will help surface any other bugs lurking here.
That latter
debug_assert_eq
assumes thatb
can be empty, is this is indeed the case?