summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/HTML5/Serializer/OutputRules.php2
-rw-r--r--test/HTML5/Serializer/OutputRulesTest.php42
2 files changed, 18 insertions, 26 deletions
diff --git a/src/HTML5/Serializer/OutputRules.php b/src/HTML5/Serializer/OutputRules.php
index d4d6bb1..a22683c 100644
--- a/src/HTML5/Serializer/OutputRules.php
+++ b/src/HTML5/Serializer/OutputRules.php
@@ -223,6 +223,8 @@ class OutputRules implements \Masterminds\HTML5\Serializer\RulesInterface
foreach ($ele->childNodes as $child) {
if ($child instanceof \DOMCharacterData) {
$this->wr($child->data);
+ } elseif ($child instanceof \DOMElement) {
+ $this->element($child);
}
}
} else {
diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php
index 1f717be..72253d3 100644
--- a/test/HTML5/Serializer/OutputRulesTest.php
+++ b/test/HTML5/Serializer/OutputRulesTest.php
@@ -627,34 +627,24 @@ class OutputRulesTest extends \Masterminds\HTML5\Tests\TestCase
{
$dom = $this->html5->loadHTML(
'<!doctype html>
- <html lang="en" id="base">
- <body>
- <p>Foo</p>
- <style id="test">
- blah
- </style>
- <p>Baz</p>
- </body>
- </html>');
-
- // modify the content of the TEXT_RAW element
- $badNode = $dom->createElement("p");
- $badNode->appendChild($dom->createTextNode("Bar"));
-
- $styleElement = $dom->getElementById("test");
+<html lang="en" id="base">
+ <body>
+ <script id="template" type="x-tmpl-mustache">
+ <h1>Hello!</h1>
+ </script>
+ </body>
+</html>');
+
+ $badNode = $dom->createElement("p", "Bar");
+
+ // modify the content of the TEXT_RAW element: <script id="template"> appending dom nodes
+ $styleElement = $dom->getElementById("template");
$styleElement->appendChild($badNode);
- // create the OutputRules instance and run the tests
- $stream = fopen('php://temp', 'w');
- $r = new OutputRules($stream, $this->html5->getOptions());
- $t = new Traverser($dom, $stream, $r, $this->html5->getOptions());
-
- $r->element($dom->getElementById('base'));
- $contents = stream_get_contents($stream, - 1, 0);
-
- $this->assertRegExp('|<p>Foo</p>|', $contents);
- $this->assertNotRegExp('|<p>Bar</p>|', $contents);
- $this->assertRegExp('|<p>Baz</p>|', $contents);
+ $contents = $this->html5->saveHTML($dom);
+ $this->assertTrue(strpos($contents, '<script id="template" type="x-tmpl-mustache">
+ <h1>Hello!</h1>
+ <p>Bar</p></script>')!==false);
}
}