diff options
Diffstat (limited to 'src/HTML5/Serializer/Traverser.php')
-rw-r--r-- | src/HTML5/Serializer/Traverser.php | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/src/HTML5/Serializer/Traverser.php b/src/HTML5/Serializer/Traverser.php index a066517..735e413 100644 --- a/src/HTML5/Serializer/Traverser.php +++ b/src/HTML5/Serializer/Traverser.php @@ -12,7 +12,31 @@ namespace HTML5\Serializer; */ class Traverser { - static $block_elements = 'html|body|head|p|div|h[1-6]|title|script|link|meta|section|article|table|tbody|tr|th|td'; + static $block_elements = array( + 'html' => 1, + 'body' => 1, + 'head' => 1, + 'p' => 1, + 'div' => 1, + 'h1' => 1, + 'h2' => 1, + 'h3' => 1, + 'h4' => 1, + 'h5' => 1, + 'h6' => 1, + 'title' => 1, + 'script' => 1, + 'link' => 1, + 'meta' => 1, + 'section' => 1, + 'article' => 1, + 'table' => 1, + 'tbody' => 1, + 'tr' => 1, + 'th' => 1, + 'td' => 1, + //'form' => 1, + ); // TODO: Refactor this into an element mask. static $literal_elements = array( @@ -33,7 +57,19 @@ class Traverser { * input, keygen, link, meta, param, source, track or wbr element, then * continue on to the next child node at this point. */ - static $unary_elements = 'area|base|basefont|bgsound|br|col|command|embed|frame|hr|img'; + static $unary_elements = array( + 'area' => 1, + 'base' => 1, + 'basefont' => 1, + 'bgsound' => 1, + 'br' => 1, + 'col' => 1, + 'command' => 1, + 'embed' => 1, + 'frame' => 1, + 'hr' => 1, + 'img' => 1, + ); /** Namespaces that should be treated as "local" to HTML5. */ static $local_ns = array( @@ -264,7 +300,7 @@ class Traverser { * True if Unary and false otherwise. */ protected function isUnary($name) { - return (bool)preg_match('/^(' . self::$unary_elements . ')$/i', $name); + return isset(self::$unary_elements[$name]); } /** @@ -277,7 +313,7 @@ class Traverser { * If the element is block level or not. */ protected function isBlock($name) { - return (bool)preg_match('/^(' . self::$block_elements . ')$/i', $name); + return isset(self::$block_elements[$name]); } /** |