From ab972a838c308eb00655ae74d3eaed4aad32ce1d Mon Sep 17 00:00:00 2001 From: "J. King" Date: Mon, 15 Feb 2021 11:34:45 -0500 Subject: [PATCH] Fix DOCTYPE serialization Also patch all top-level comments out --- lib/DOM/Document.php | 1 - lib/DOM/DocumentType.php | 16 ---------------- tests/cases/TestTreeConstructor.php | 26 ++++++++++++++++++-------- 3 files changed, 18 insertions(+), 25 deletions(-) delete mode 100644 lib/DOM/DocumentType.php diff --git a/lib/DOM/Document.php b/lib/DOM/Document.php index 4126f28..7ed8448 100644 --- a/lib/DOM/Document.php +++ b/lib/DOM/Document.php @@ -10,7 +10,6 @@ class Document extends \DOMDocument { $this->registerNodeClass('DOMComment', '\dW\HTML5\Comment'); $this->registerNodeClass('DOMDocumentFragment', '\dW\HTML5\DocumentFragment'); - $this->registerNodeClass('DOMDocumentType', '\dW\HTML5\DocumentType'); $this->registerNodeClass('DOMElement', '\dW\HTML5\Element'); $this->registerNodeClass('DOMProcessingInstruction', '\dW\HTML5\ProcessingInstruction'); $this->registerNodeClass('DOMText', '\dW\HTML5\Text'); diff --git a/lib/DOM/DocumentType.php b/lib/DOM/DocumentType.php deleted file mode 100644 index 0d7552f..0000000 --- a/lib/DOM/DocumentType.php +++ /dev/null @@ -1,16 +0,0 @@ -" (U+003E - # GREATER-THAN SIGN). - return "name}>"; - } -} diff --git a/tests/cases/TestTreeConstructor.php b/tests/cases/TestTreeConstructor.php index ad0dad9..c61bd39 100644 --- a/tests/cases/TestTreeConstructor.php +++ b/tests/cases/TestTreeConstructor.php @@ -33,7 +33,10 @@ class TestTreeConstructor extends \PHPUnit\Framework\TestCase { $this->markTestIncomplete("Fragment tests still to be implemented"); } // certain tests need to be patched to ignore unavoidable limitations of PHP's DOM - $exp = $this->patchTest($data, $fragment, $exp); + [$exp, $patched] = $this->patchTest($data, $fragment, $exp); + if ($patched) { + $this->markAsRisky(); + } // convert parse error constants into standard symbols in specification $errorMap = array_map(function($str) { return strtolower(str_replace("_", "-", $str)); @@ -72,11 +75,15 @@ class TestTreeConstructor extends \PHPUnit\Framework\TestCase { } protected function patchTest(string $data, $fragment, array $exp): array { - if (strpos($exp[0], "|