diff options
author | Matt Farina <[email protected]> | 2014-06-09 20:48:53 -0400 |
---|---|---|
committer | Matt Farina <[email protected]> | 2014-06-09 20:48:53 -0400 |
commit | 04f2b92e763b08d338268ce0818554616b7141cd (patch) | |
tree | f74532363aeb5d958d12a9a71247b25f7efc841c /test/HTML5/Serializer | |
parent | c7a3b2e98680d8c138a3733ce3ee161c99743280 (diff) |
Added a test to verify we don't have a script being cut off part way though as in QueryPath #136.
Diffstat (limited to 'test/HTML5/Serializer')
-rw-r--r-- | test/HTML5/Serializer/OutputRulesTest.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php index 8326ef9..9a022c5 100644 --- a/test/HTML5/Serializer/OutputRulesTest.php +++ b/test/HTML5/Serializer/OutputRulesTest.php @@ -97,6 +97,40 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { $this->assertEquals('<div id="foo" class="bar baz">foo bar baz</div>', stream_get_contents($stream, -1, 0)); } + function testElementWithScript() { + $dom = \HTML5::loadHTML('<!doctype html> + <html lang="en"> + <head> + <script> + var $jQ = jQuery.noConflict(); + // Use jQuery via $jQ(...) + $jQ(document).ready(function(){ + $jQ("#mktFrmSubmit").wrap("<div class=\'buttonSubmit\'></div>"); + $jQ(".buttonSubmit").prepend("<span></span>"); + }); + </script> + </head> + <body> + <div id="foo" class="bar baz">foo bar baz</div> + </body> + </html>'); + + $stream = fopen('php://temp', 'w'); + $r = new OutputRules($stream, \HTML5::options()); + $t = new Traverser($dom, $stream, $r, \HTML5::options()); + + $script = $dom->getElementsByTagName('script'); + $r->element($script->item(0)); + $this->assertEquals('<script> + var $jQ = jQuery.noConflict(); + // Use jQuery via $jQ(...) + $jQ(document).ready(function(){ + $jQ("#mktFrmSubmit").wrap("<div class=\'buttonSubmit\'></div>"); + $jQ(".buttonSubmit").prepend("<span></span>"); + }); + </script>', stream_get_contents($stream, -1, 0)); + } + function testOpenTag() { $dom = \HTML5::loadHTML('<!doctype html> <html lang="en"> |