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

Wrong missing Child Element in HTML Comparison Using Diffing Strategy Pipeline #47

Open
starsibi opened this issue Oct 28, 2024 Discussed in #46 · 2 comments
Open

Wrong missing Child Element in HTML Comparison Using Diffing Strategy Pipeline #47

starsibi opened this issue Oct 28, 2024 Discussed in #46 · 2 comments

Comments

@starsibi
Copy link

Discussed in #46

Originally posted by starsibi October 27, 2024
Am I missing something here? I'm facing an issue where the expected output, <div class="child2">child2</div>, is missing in testHTML, but it's actually returning <div class="child3">child3</div>. Could you share your thoughts on this?

Thanks in advance!

var strategy = new DiffingStrategyPipeline();
strategy.AddDefaultOptions();

// Create the differ and pass in the strategy
var differ = new HtmlDiffer(strategy);

// Use the differ to compare markup
var controlHtml = "<div class="parent">\r\n <div class="child1">child1\r\n <div class="child2">child2\r\n <div class="child3">child3\r\n";
var testHtml = "<div class="parent">\r\n <div class="child1">child1\r\n <div class="child3">child3\r\n";
var diffs = differ.Compare(controlHtml, testHtml);
```</div>
@egil
Copy link
Collaborator

egil commented Oct 29, 2024

First thought is that the test and control HTML is not valid, it's missing closing DIV tags. I am not sure what the html tree looks like in that case and that may be the reason for the behavior.

@starsibi
Copy link
Author

@egil : Apologies, my mistake. Here is the correct test and control HTML.

var controlHtml = "<div class=\"parent\">\r\n  <div class=\"child1\">child1</div>\r\n  <div class=\"child2\">child2</div>\r\n  <div class=\"child3\">child3</div>\r\n</div>";
    var testHtml = "<div class=\"parent\">\r\n  <div class=\"child1\">child1</div>\r\n  <div class=\"child3\">child3</div>\r\n</div>";

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

No branches or pull requests

2 participants