@@ -627,34 +627,24 @@ public function testHandlingInvalidRawContent()
627627 {
628628 $ dom = $ this ->html5 ->loadHTML (
629629 '<!doctype html>
630- <html lang="en" id="base">
631- <body>
632- <p>Foo</p>
633- <style id="test">
634- blah
635- </style>
636- <p>Baz</p>
637- </body>
638- </html> ' );
639-
640- // modify the content of the TEXT_RAW element
641- $ badNode = $ dom ->createElement ("p " );
642- $ badNode ->appendChild ($ dom ->createTextNode ("Bar " ));
643-
644- $ styleElement = $ dom ->getElementById ("test " );
630+ <html lang="en" id="base">
631+ <body>
632+ <script id="template" type="x-tmpl-mustache">
633+ <h1>Hello!</h1>
634+ </script>
635+ </body>
636+ </html> ' );
637+
638+ $ badNode = $ dom ->createElement ("p " , "Bar " );
639+
640+ // modify the content of the TEXT_RAW element: <script id="template"> appending dom nodes
641+ $ styleElement = $ dom ->getElementById ("template " );
645642 $ styleElement ->appendChild ($ badNode );
646643
647- // create the OutputRules instance and run the tests
648- $ stream = fopen ('php://temp ' , 'w ' );
649- $ r = new OutputRules ($ stream , $ this ->html5 ->getOptions ());
650- $ t = new Traverser ($ dom , $ stream , $ r , $ this ->html5 ->getOptions ());
651-
652- $ r ->element ($ dom ->getElementById ('base ' ));
653- $ contents = stream_get_contents ($ stream , - 1 , 0 );
654-
655- $ this ->assertRegExp ('|<p>Foo</p>| ' , $ contents );
656- $ this ->assertNotRegExp ('|<p>Bar</p>| ' , $ contents );
657- $ this ->assertRegExp ('|<p>Baz</p>| ' , $ contents );
644+ $ contents = $ this ->html5 ->saveHTML ($ dom );
658645
646+ $ this ->assertTrue (strpos ($ contents , '<script id="template" type="x-tmpl-mustache">
647+ <h1>Hello!</h1>
648+ <p>Bar</p></script> ' )!==false );
659649 }
660650}
0 commit comments