This class provides DOM helpers useful for extensions.
More...
|
static | hasTypeOf (Node $node, string $type) |
| Test if a node matches a given typeof.
|
|
static | hasClass (Element $element, string $regex) |
|
static | matchTypeOf (Node $n, string $typeRe) |
| Determine whether the node matches the given typeof attribute value.
|
|
static | addTypeOf (Element $elt, string $type) |
| Add a type to the typeof attribute.
|
|
static | removeTypeOf (Element $elt, string $type) |
| Remove a type from the typeof attribute.
|
|
static | matchRel (Node $n, string $rel) |
| Determine whether the node matches the given rel attribute value.
|
|
static | addRel (Element $node, string $rel) |
| Add a type to the rel attribute.
|
|
static | assertElt (?Node $node) |
| Assert that this is a DOM element node.
|
|
static | migrateChildren (Node $from, Node $to, ?Node $beforeNode=null) |
| Move 'from'.childNodes to 'to' adding them before 'beforeNode' If 'beforeNode' is null, the nodes are appended at the end.
|
|
static | addAttributes (Element $elt, array $attrs) |
| Add attributes to a node element.
|
|
static | findAncestorOfName (Node $node, string $name) |
| Find an ancestor of $node with nodeName $name.
|
|
This class provides DOM helpers useful for extensions.
◆ addAttributes()
static Wikimedia\Parsoid\Ext\DOMUtils::addAttributes |
( |
Element | $elt, |
|
|
array | $attrs ) |
|
static |
Add attributes to a node element.
- Parameters
-
Element | $elt | element |
array | $attrs | attributes |
◆ addRel()
static Wikimedia\Parsoid\Ext\DOMUtils::addRel |
( |
Element | $node, |
|
|
string | $rel ) |
|
static |
Add a type to the rel attribute.
This method should almost always be used instead of setAttribute
, to ensure we don't overwrite existing rel information.
- Parameters
-
Element | $node | node |
string | $rel | type |
◆ addTypeOf()
static Wikimedia\Parsoid\Ext\DOMUtils::addTypeOf |
( |
Element | $elt, |
|
|
string | $type ) |
|
static |
Add a type to the typeof attribute.
If the elt already has an existing typeof, it makes that attribute a string of space separated types.
- Parameters
-
Element | $elt | |
string | $type | type |
◆ assertElt()
static Wikimedia\Parsoid\Ext\DOMUtils::assertElt |
( |
?Node | $node | ) |
|
|
static |
Assert that this is a DOM element node.
This is primarily to help phan analyze variable types. @phan-assert Element $node
- Parameters
-
- Returns
- bool Always returns true
◆ findAncestorOfName()
static Wikimedia\Parsoid\Ext\DOMUtils::findAncestorOfName |
( |
Node | $node, |
|
|
string | $name ) |
|
static |
Find an ancestor of $node with nodeName $name.
- Parameters
-
- Returns
- ?Element
◆ hasClass()
static Wikimedia\Parsoid\Ext\DOMUtils::hasClass |
( |
Element | $element, |
|
|
string | $regex ) |
|
static |
- Parameters
-
Element | $element | |
string | $regex | Partial regular expression, e.g. "foo|bar" |
- Returns
- bool
◆ hasTypeOf()
static Wikimedia\Parsoid\Ext\DOMUtils::hasTypeOf |
( |
Node | $node, |
|
|
string | $type ) |
|
static |
Test if a node matches a given typeof.
- Parameters
-
Node | $node | node |
string | $type | type |
- Returns
- bool
◆ matchRel()
static Wikimedia\Parsoid\Ext\DOMUtils::matchRel |
( |
Node | $n, |
|
|
string | $rel ) |
|
static |
Determine whether the node matches the given rel attribute value.
- Parameters
-
Node | $n | |
string | $rel | Expected value of "rel" attribute, as a literal string. |
- Returns
- ?string The match if there is one, null otherwise
◆ matchTypeOf()
static Wikimedia\Parsoid\Ext\DOMUtils::matchTypeOf |
( |
Node | $n, |
|
|
string | $typeRe ) |
|
static |
Determine whether the node matches the given typeof
attribute value.
- Parameters
-
Node | $n | The node to test |
string | $typeRe | Regular expression matching the expected value of the typeof attribute. |
- Returns
- ?string The matching
typeof
value, or null
if there is no match.
◆ migrateChildren()
static Wikimedia\Parsoid\Ext\DOMUtils::migrateChildren |
( |
Node | $from, |
|
|
Node | $to, |
|
|
?Node | $beforeNode = null ) |
|
static |
Move 'from'.childNodes to 'to' adding them before 'beforeNode' If 'beforeNode' is null, the nodes are appended at the end.
- Parameters
-
Node | $from | Source node. Children will be removed. |
Node | $to | Destination node. Children of $from will be added here |
?Node | $beforeNode | Add the children before this node. |
◆ removeTypeOf()
static Wikimedia\Parsoid\Ext\DOMUtils::removeTypeOf |
( |
Element | $elt, |
|
|
string | $type ) |
|
static |
Remove a type from the typeof attribute.
- Parameters
-
Element | $elt | |
string | $type | type |
The documentation for this class was generated from the following file: