diff options
author | Matt Farina <[email protected]> | 2013-04-29 15:45:40 -0500 |
---|---|---|
committer | Matt Farina <[email protected]> | 2013-04-29 15:45:40 -0500 |
commit | 56d9b965f6d81f540a75786fae3800fc513985d6 (patch) | |
tree | 166bcefd338e8db3a5f1bdd27175dcd0014534c2 /src/HTML5 | |
parent | be7f40d38223cf6cf4aa1ce180de9e3bd36672c5 (diff) |
Moved the traverser unary tests to the elements class.
Diffstat (limited to 'src/HTML5')
-rw-r--r-- | src/HTML5/Elements.php | 7 | ||||
-rw-r--r-- | src/HTML5/Serializer/Traverser.php | 39 |
2 files changed, 7 insertions, 39 deletions
diff --git a/src/HTML5/Elements.php b/src/HTML5/Elements.php index afa3327..429dbbf 100644 --- a/src/HTML5/Elements.php +++ b/src/HTML5/Elements.php @@ -35,12 +35,12 @@ class Elements { "a" => 1, "abbr" => 1, "address" => 25, // NORMAL | UNARY_TAG | AUTOCLOSE_P - "area" => 1, + "area" => 9, // NORMAL | UNARY_TAG "article" => 17, // NORMAL | AUTOCLOSE_P "aside" => 17, // NORMAL | AUTOCLOSE_P, "audio" => 1, "b" => 1, - "base" => 9, // | UNARY_TAG + "base" => 9, // NORMAL | UNARY_TAG "bdi" => 1, "bdo" => 1, "blockquote" => 17, // NORMAL | AUTOCLOSE_P, @@ -51,7 +51,7 @@ class Elements { "caption" => 1, "cite" => 1, "code" => 1, - "col" => 1, + "col" => 9, // NORMAL | UNARY_TAG "colgroup" => 1, "command" => 9, // NORMAL | UNARY_TAG //"data" => 1, // This is highly experimental and only part of the whatwg spec (not w3c). See https://developer.mozilla.org/en-US/docs/HTML/Element/data @@ -147,6 +147,7 @@ class Elements { 'basefont' => 8, // UNARY_TAG 'bgsound' => 8, // UNARY_TAG 'noframes' => 2, // RAW_TEXT + 'frame' => 9, // NORMAL | UNARY_TAG 'center' => 16, 'dir' => 16, 'listing' => 16, // AUTOCLOSE_P 'plaintext' => 48, // AUTOCLOSE_P | TEXT_PLAINTEXT 'applet' => 0, diff --git a/src/HTML5/Serializer/Traverser.php b/src/HTML5/Serializer/Traverser.php index 735e413..cdbd64a 100644 --- a/src/HTML5/Serializer/Traverser.php +++ b/src/HTML5/Serializer/Traverser.php @@ -1,6 +1,8 @@ <?php namespace HTML5\Serializer; +use \HTML5\Elements; + /** * Traverser for walking a DOM tree. * @@ -49,28 +51,6 @@ class Traverser { 'plaintext' => 1, ); - /** - * Unary elements. - * HTML5 section 8.3: - * If current node is an - * area, base, basefont, bgsound, br, col, command, embed, frame, hr, img, - * input, keygen, link, meta, param, source, track or wbr element, then - * continue on to the next child node at this point. - */ - 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( 'http://www.w3.org/1999/xhtml' => 'html', @@ -199,7 +179,7 @@ class Traverser { } // If not unary, add a closing tag. - if (!$this->isUnary($name)) { + if (Elements::isA($name, Elements::UNARY_TAG)) { $this->closeTag($ele); if ($block) $this->nl(); } @@ -291,19 +271,6 @@ class Traverser { } /** - * Is an unary tag. - * - * @param string $name - * The name of the element to test. - * - * @return bool - * True if Unary and false otherwise. - */ - protected function isUnary($name) { - return isset(self::$unary_elements[$name]); - } - - /** * Is block element. * * @param string $name |