Helper class that provides missing DOM level 3 methods for the PHP DOM classes.
More...
|
static | newDocument (bool $isHtml) |
| Create a new empty document.
|
|
static | nodeName (Node $node) |
| Return the lower-case version of the node name (HTML says this should be capitalized).
|
|
static | getTitle ( $document) |
| Get document title.
|
|
static | setTitle ( $document, string $title) |
| Set document title.
|
|
static | getElementById ( $node, string $id) |
| Return the descendant with the specified ID.
|
|
static | setIdAttribute ( $element, string $id) |
| Workaround bug in PHP's Document::getElementById() which doesn't actually index the 'id' attribute unless you use the non-standard Element::setIdAttribute method after the attribute is set; see https://www.php.net/manual/en/domdocument.getelementbyid.php for more details.
|
|
static | getElementsByTagName ( $node, string $tagName) |
| Return all descendants with the specified tag name.
|
|
static | getLastElementChild ( $node) |
| Return the last child of the node that is an Element, or null otherwise.
|
|
static | querySelector ( $node, string $selector) |
|
static | querySelectorAll ( $node, string $selector) |
|
static | getPreviousElementSibling ( $node) |
| Return the last preceding sibling of the node that is an element, or null otherwise.
|
|
static | getNextElementSibling ( $node) |
| Return the first following sibling of the node that is an element, or null otherwise.
|
|
static | remove ( $node) |
| Removes the node from the document.
|
|
static | getInnerHTML ( $element) |
| Get innerHTML.
|
|
static | setInnerHTML ( $element, string $html) |
| Set innerHTML.
|
|
static | getOuterHTML ( $element) |
| Get outerHTML.
|
|
static | getClassList ( $node) |
| Return the class list of this element.
|
|
static | normalize ( $elt) |
|
static | replaceChildren ( $parentNode,... $nodes) |
| ParentNode.replaceChildren() https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/replaceChildren.
|
|
Helper class that provides missing DOM level 3 methods for the PHP DOM classes.
For a DOM method $node->foo( $bar) the equivalent helper is DOMCompat::foo( $node, $bar ). For a DOM property $node->foo there is a DOMCompat::getFoo( $node ) and DOMCompat::setFoo( $node, $value ).
Only implements the methods that are actually used by Parsoid.
Because this class may be used by code outside Parsoid it tries to be relatively tolerant of object types: you can call it either with PHP's DOM* types or with a "proper" DOM implementation, and it will attempt to Do The Right Thing regardless. As a result there are generally not parameter type hints for DOM object types, and the return types will be broad enough to accomodate the value a "real" DOM implementation would return, as well as the values our thunk will return. (For instance, we can't create a "real" NodeList in our compatibility thunk.)