Serializer optimization

This commit is contained in:
Dustin Wilson 2021-03-19 14:20:57 -05:00
parent fbefea3073
commit fa4cd1e09f

View file

@ -3,9 +3,11 @@ declare(strict_types=1);
namespace dW\HTML5;
trait Serialize {
protected static $voidElements = [ 'area', 'base', 'basefont', 'bgsound', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr' ];
protected function serializesAsVoid(): bool {
$name = $this->nodeName;
if ($name === 'area' || $name === 'base' || $name === 'basefont' || $name === 'bgsound' || $name === 'br' || $name === 'col' || $name === 'embed' || $name === 'hr' || $name === 'img' || $name === 'input' || $name === 'link' || $name === 'meta' || $name === 'param' || $name === 'source' || $name === 'track' || $name === 'wbr') {
if (in_array($name, self::$voidElements)) {
return true;
}