Modern DOM library written in PHP for HTML documents
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.5 KiB

<?php
declare(strict_types=1);
namespace dW\HTML5;
class Element extends \DOMElement {
use Ancestor, Descendant {
Ancestor::compare insteadof Descendant;
}
// Used for template elements
public $content = null;
public function __construct(string $name, string $value = '', string $namespaceURI = '') {
parent::__construct($name, $value, $namespaceURI);
if ($name === 'template' && $namespaceURI === '') {
$this->content = $this->ownerDocument->createDocumentFragment();
}
}
public function isMathMLTextIntegrationPoint(): bool {
return (
$this->namespaceURI === Parser::MATHML_NAMESPACE && (
$this->nodeName === 'mi' || $this->nodeName === 'mo' || $this->nodeName === 'mn' || $this->nodeName === 'ms' || $this->nodeName === 'mtext'
)
);
}
public function isHTMLIntegrationPoint(): bool {
$encoding = strtolower($this->getAttribute('encoding'));
return ((
$this->namespaceURI === Parser::MATHML_NAMESPACE &&
$this->nodeName === 'annotation-xml' && (
$encoding === 'text/html' || $encoding === 'application/xhtml+xml'
)
) || (
$this->namespaceURI === Parser::SVG_NAMESPACE && (
$this->nodeName === 'foreignObject' || $this->nodeName === 'desc' || $this->nodeName === 'title'
)
)
);
}
}