public function setOutputMode($mode)
{
if (!in_array($mode, [self::HTML4_TRANSITIONAL, self::HTML4_STRICT, self::HTML5, self::XHTML1_TRANSITIONAL, self::XHTML1_STRICT, self::XHTML5], TRUE)) {
throw new \InvalidArgumentException('Invalid mode.');
}
if (!isset(self::$dtdCache[$mode])) {
self::$dtdCache[$mode] = (require __DIR__ . '/DTD.php');
}
$this->mode = $mode;
$this->dtd = self::$dtdCache[$mode];
HtmlElement::$xhtml = (bool) ($mode & self::XML);
// TODO: remove?
// accept all valid HTML tags and attributes by default
$this->allowedTags = [];
foreach ($this->dtd as $tag => $dtd) {
$this->allowedTags[$tag] = self::ALL;
}
}