Git Product home page Git Product logo

Comments (7)

chinedufn avatar chinedufn commented on July 28, 2024 1

Thanks a lot for pointing this out!

Are you using console_error_panic_hook? If not that helps tremendously with the stack traces.

Maybe you can reproduce this somehow in a test? I currently don't know how.

So we typically just create a new diff_patch.rs test case and see if it fails.

#[wasm_bindgen_test]
fn replace_child() {
DiffPatchTest {
desc: "Replace a root node attribute attribute and a child text node",
old: html! {
<div>
Original element
</div>
},
new: html! { <div> Patched element</div> },
override_expected: None,
}
.test();
}

wasm-pack test crates/virtual-dom-rs --firefox --headless --test diff_patch # Run browser tests

These tests make sure that you can diff and patch in both directions between two VirtualNode trees.

Basically it's the change from <span><br></span> to <span>a<br></span>.

I've been able to reproduce the issue thanks to your example

https://github.com/chinedufn/percy/blob/fix-62/crates/virtual-dom-rs/tests/diff_patch.rs#L163-L173

Will take a look (not tonight).

Thanks!!

from percy.

dbrgn avatar dbrgn commented on July 28, 2024 1

Great! I can probably give this a try tomorrow (unless you find time tonight).

from percy.

chinedufn avatar chinedufn commented on July 28, 2024

FWIW another place that relates to this is the html macro tests

#[test]
fn vec_of_nodes() {
let children = vec![html! { <div> </div>}, html! { <strong> </strong>}];
let mut expected = VirtualNode::new("div");
expected.children = Some(vec![VirtualNode::new("div"), VirtualNode::new("strong")]);
HtmlMacroTest {
desc: "Vec of nodes",
generated: html! { <div> { children } </div> },
expected,
}
.test();
}

But I took a look and the html macro is working fine so this looks like a diff or patch issue... I'll take a look

from percy.

dbrgn avatar dbrgn commented on July 28, 2024

Are you using console_error_panic_hook? If not that helps tremendously with the stack traces.

Oh, that's nice, thanks for pointing it out!

from percy.

chinedufn avatar chinedufn commented on July 28, 2024

Alright so I won't be able to take a look for a few days.

If you'd like to take a look at this in the meantime I'd be happy to answer any questions and/or point you towards where to look.

I've written up some documentation on the exact process to figure out what's going wrong.

https://chinedufn.github.io/percy/diff-patch/fixing-diff-patch-issues.html

image

from percy.

chinedufn avatar chinedufn commented on July 28, 2024

Alright so I added a test case with your example (thanks!) and it does indeed fail!

// https://github.com/chinedufn/percy/issues/62
#[test]
fn issue_62() {
DiffTestCase {
old: html! { <span> <br /> </span> },
new: html! { <span> a <br /> </span> },
expected: vec![
Patch::Replace(1, &VirtualNode::text("a")),
Patch::AppendChildren(0, vec![&VirtualNode::new("br")]),
],
description: "Replace text node",
}
.test();
}

image

Just to keep you posted, I should be able to take a look either tonight or within the next couple of days.

Cheers!

from percy.

chinedufn avatar chinedufn commented on July 28, 2024

@dbrgn so my screenshot above was totally wrong. The diffing was working fine I just had my Vec<Patch> in the test case backwards. The left and right in that screenshot have the save vector contents just in different orders...

Anyways.. the real issue was a patching issue.

The Patch::Replace(...) handler would treat text nodes like regular nodes so we were trying to create an element but we weren't providing a tag.. So basically calling document.create_element("");

#65

from percy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.