diff options
author | Matt Farina <[email protected]> | 2014-06-09 20:57:17 -0400 |
---|---|---|
committer | Matt Farina <[email protected]> | 2014-06-09 20:57:17 -0400 |
commit | d7cb5f181fe48025a3a2e7f0c7d6cd2acf8cd3d0 (patch) | |
tree | 89d3357096e85aa2f6b9716675e47e75afa1699e | |
parent | 04f2b92e763b08d338268ce0818554616b7141cd (diff) |
#32 Fixed bug where character references were being encoded in style tags.
-rw-r--r-- | src/HTML5/Elements.php | 2 | ||||
-rw-r--r-- | test/HTML5/Html5Test.php | 4 | ||||
-rw-r--r-- | test/HTML5/Serializer/OutputRulesTest.php | 28 |
3 files changed, 31 insertions, 3 deletions
diff --git a/src/HTML5/Elements.php b/src/HTML5/Elements.php index 69d3882..678b3ac 100644 --- a/src/HTML5/Elements.php +++ b/src/HTML5/Elements.php @@ -148,7 +148,7 @@ class Elements { "source" => 9, // NORMAL | VOID_TAG "span" => 1, "strong" => 1, - "style" => 1, + "style" => 3, // NORMAL | TEXT_RAW "sub" => 1, "summary" => 17, // NORMAL | AUTOCLOSE_P, "sup" => 1, diff --git a/test/HTML5/Html5Test.php b/test/HTML5/Html5Test.php index 29ce83b..e30a3e3 100644 --- a/test/HTML5/Html5Test.php +++ b/test/HTML5/Html5Test.php @@ -288,13 +288,13 @@ class Html5Test extends TestCase { $this->assertRegExp('|2 < 1|', $res); $res = $this->cycle('<style>div>div>div</style>'); - $this->assertRegExp('|div>div>div|', $res); + $this->assertRegExp('|div>div>div|', $res); $res = $this->cycleFragment('<script>2 < 1</script>'); $this->assertRegExp('|2 < 1|', $res); $res = $this->cycleFragment('<style>div>div>div</style>'); - $this->assertRegExp('|div>div>div|', $res); + $this->assertRegExp('|div>div>div|', $res); } public function testEntities() { diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php index 9a022c5..6ef8304 100644 --- a/test/HTML5/Serializer/OutputRulesTest.php +++ b/test/HTML5/Serializer/OutputRulesTest.php @@ -131,6 +131,34 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { </script>', stream_get_contents($stream, -1, 0)); } + function testElementWithStyle() { + $dom = \HTML5::loadHTML('<!doctype html> + <html lang="en"> + <head> + <style> + body > .bar { + display: none; + } + </style> + </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()); + + $style = $dom->getElementsByTagName('style'); + $r->element($style->item(0)); + $this->assertEquals('<style> + body > .bar { + display: none; + } + </style>', stream_get_contents($stream, -1, 0)); + } + function testOpenTag() { $dom = \HTML5::loadHTML('<!doctype html> <html lang="en"> |