From c5099f50fd68f26741d061cff5a3ccd086e00cfe Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Wed, 1 May 2013 14:55:36 -0500 Subject: Fixes for PI tests. --- src/HTML5/Parser/DOMTreeBuilder.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/HTML5') diff --git a/src/HTML5/Parser/DOMTreeBuilder.php b/src/HTML5/Parser/DOMTreeBuilder.php index 4e2669c..686effc 100644 --- a/src/HTML5/Parser/DOMTreeBuilder.php +++ b/src/HTML5/Parser/DOMTreeBuilder.php @@ -266,6 +266,11 @@ class DOMTreeBuilder implements EventHandler { } public function processingInstruction($name, $data = NULL) { + // XXX: Ignore initial XML declaration, per the spec. + if ($this->insertMode == self::IM_INITIAL && 'xml' == strtolower($name)) { + return; + } + // Important: The processor may modify the current DOM tree however // it sees fit. if (isset($this->processor)) { @@ -273,7 +278,13 @@ class DOMTreeBuilder implements EventHandler { if (!empty($res)) { $this->current = $res; } + return; } + + // Otherwise, this is just a dumb PI element. + $node = $this->doc->createProcessingInstruction($name, $data); + + $this->current->appendChild($node); } // ========================================================================== -- cgit v1.2.3