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

Strange results when removing list items #4

Open
voehl opened this issue Jun 7, 2016 · 1 comment
Open

Strange results when removing list items #4

voehl opened this issue Jun 7, 2016 · 1 comment

Comments

@voehl
Copy link

voehl commented Jun 7, 2016

Hello,

first of all I would like to thank you for your amazing library which satisfies almost all of our use cases.

While testing the library I discovered that removing items from lists don't seem to work.

The case

Old HTML:

<ol>
    <li>1</li>
    <li>2</li>
    <li>3</li>
</ol>

New HTML (first and second list item removed):

<ol>
    <li>3</li>
</ol>

Expected result:

<ol>
    <li><del class="diff-html-removed" id="removed-htmldiff-0">1</del></li>
    <li><del class="diff-html-removed" id="removed-htmldiff-1">2</del></li>
    <li>3</li>
</ol>

Actual result:

<li>
    <del class="diff-html-removed" id="removed-htmldiff-0">1</del>
</li>
<ol>
    <li>3</li>
</ol>

So the first <li>-element got moved out of the <ol>-Container and the second <li>-Element did just disappear.

Code to reproduce bug:

<?php
require_once 'vendor/autoload.php';

$old = '<ol><li>1</li><li>2</li><li>3</li></ol>';
$new = '<ol><li>3</li></ol>';

$diff = new Icap\HtmlDiff\HtmlDiff($old, $new, true);
$out = $diff->outputDiff();
echo $out->toString();

You dont have to use a <ol>-Element to reproduce this bug. It happens on every element:
Old HTML: <testing><asd>1</asd><asd>2</asd><asd>3</asd></testing>
New HTML: <testing><asd>3</asd></testing>
Result:

<asd>
    <del class="diff-html-removed" id="removed-htmldiff-0">1</del>
</asd>
<testing>
    <asd>3</asd>
</testing>

I would kindly appreciate any help or idea on how to fix this issue.

Thanks and best regards,
Niklas

@ptsavdar
Copy link
Contributor

ptsavdar commented Jul 8, 2016

Hello, thank you for your kind words. Unfortunately is's been a long time since the last time I worked on this library and at the moment I don't know if I'll be able to find some time and take a look at this issue. But I promise to try my best. Thank you again for your feedback.

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