php-htmldiff icon indicating copy to clipboard operation
php-htmldiff copied to clipboard

nested/unclosed tags on attribute differences

Open ESI-Lille-devops opened this issue 2 years ago • 0 comments

When comparing identical tags (tag and content), of which one has an attribute that the other doesn't, the produced output presents two opening tags, the identical content, and only one closing tag. Also, although I am not sure of what the expected behavior is, if both have the attribute, with different values, no difference is detected and the output is the old html. The following code

<?php

require_once 'vendor/autoload.php';

use Caxy\HtmlDiff\HtmlDiff;

function compare($old, $new) {
    echo (new HtmlDiff($new, $old))->build() . "\n";
}

compare(
    '<p title="A">content</p>',
    '<p>content</p>'
);
compare(
    '<p>content</p>',
    '<p class="A">content</p>'
);
compare(
    '<p title="A">content</p>',
    '<p title="B">content</p>'
);

outputs the following :

<p class="diffmod"><p title="A" class="diffmod">content</p>
<p class="diffmod A"><p class="diffmod">content</p>
<p title="A">content</p>

ESI-Lille-devops avatar Nov 29 '22 12:11 ESI-Lille-devops