-
Notifications
You must be signed in to change notification settings - Fork 116
Closed
Description
Parsing self closing <tr> and <td> in combination results in the rows being nested instead of siblings.
Here's a minimal test case:
<?php
use Masterminds\HTML5;
use PHPUnit\Framework\TestCase;
class SelfClosingTableTest extends TestCase
{
public function testHtml5Spec(): void
{
$html5 = new HTML5();
$html = '<table><tr><td>A<tr><td>B</table>';
$doc = $html5->loadHTMLFragment($html);
$this->assertSame(
'<table><tr><td>A</td></tr><tr><td>B</td></tr></table>',
$html5->saveHTML($doc),
);
}
}Which outputs:
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'<table><tr><td>A</td></tr><tr><td>B</td></tr></table>'
+'<table><tr><td>A<tr><td>B</td></tr></td></tr></table>'
I first encountered this issue when parsing the HTML spec 😸 https://html.spec.whatwg.org/multipage/indices.html#attributes-1
Metadata
Metadata
Assignees
Labels
No labels