Skip to content

nested/unclosed tags on attribute differences #113

@ESI-Lille-devops

Description

@ESI-Lille-devops

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions