Parsoid
A bidirectional parser between wikitext and HTML5
Loading...
Searching...
No Matches
Wikimedia\Parsoid\Utils\DOMUtils Class Reference

DOM utilities for querying the DOM. More...

Static Public Member Functions

static parseHTML (string $html, bool $validateXMLNames=false)
 Parse HTML, return the tree.
 
static visitDOM (Node $node, callable $handler,... $args)
 This is a simplified version of the DOMTraverser.
 
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 migrateChildrenBetweenDocs (Node $from, Node $to, ?Node $beforeNode=null)
 Copy 'from'.childNodes to 'to' adding them before 'beforeNode' 'from' and 'to' belong to different documents.
 
static assertElt (?Node $node)
 Assert that this is a DOM element node.
 
static isRemexBlockNode (?Node $node)
 
static isWikitextBlockNode (?Node $node)
 
static isFormattingElt (?Node $node)
 Determine whether this is a formatting DOM element.
 
static isQuoteElt (?Node $node)
 Determine whether this is a quote DOM element.
 
static isBody (?Node $node)
 Determine whether this is the <body> DOM element.
 
static isRemoved (?Node $node)
 Determine whether this is a removed DOM node but Node object yet.
 
static hasNChildren (Node $node, int $nchildren, bool $countDiffMarkers=false)
 Test the number of children this node has without using DOMNode::$childNodes->count().
 
static pathToAncestor (Node $node, ?Node $ancestor=null)
 Build path from a node to its passed-in ancestor.
 
static pathToRoot (Node $node)
 Build path from a node to the root of the document.
 
static pathToSibling (Node $node, Node $sibling, bool $left)
 Build path from a node to its passed-in sibling.
 
static inSiblingOrder (Node $n1, Node $n2)
 Check whether a node n1 comes before another node n2 in their parent's children list.
 
static isAncestorOf (Node $n1, Node $n2)
 Check that a node 'n1' is an ancestor of another node 'n2' in the DOM.
 
static findAncestorOfName (Node $node, string $name)
 Find an ancestor of $node with nodeName $name.
 
static hasNameOrHasAncestorOfName (Node $node, string $name)
 Check whether $node has $name or has an ancestor named $name.
 
static matchNameAndTypeOf (Node $n, string $name, string $typeRe)
 Determine whether the node matches the given nodeName and attribute value.
 
static hasNameAndTypeOf (Node $n, string $name, string $type)
 Determine whether the node matches the given nodeName and typeof attribute value; the typeof is given as string.
 
static matchTypeOf (Node $n, string $typeRe)
 Determine whether the node matches the given typeof attribute value.
 
static matchRel (Node $n, string $relRe)
 Determine whether the node matches the given rel attribute value.
 
static matchMultivalAttr (Node $n, string $attrName, string $valueRe)
 Determine whether the node matches the given multivalue attribute value.
 
static hasTypeOf (Node $n, string $type)
 Determine whether the node matches the given typeof attribute value.
 
static hasRel (Node $n, string $rel)
 Determine whether the node matches the given rel attribute value.
 
static hasValueInMultivalAttr (Node $n, string $attrName, string $value)
 Determine whether the node matches the given attribute value for a multivalued attribute.
 
static addTypeOf (Element $node, string $type)
 Add a type to the typeof attribute.
 
static addRel (Element $node, string $rel)
 Add a type to the rel attribute.
 
static addValueToMultivalAttr (Element $node, string $attr, string $value)
 Add an element to a multivalue attribute (typeof, rel).
 
static removeTypeOf (Element $node, string $type)
 Remove a type from the typeof attribute.
 
static isFosterablePosition (?Node $n)
 Check whether node is in a fosterable position.
 
static isHeading (?Node $n)
 Check whether node is a heading.
 
static isList (?Node $n)
 Check whether node is a list.
 
static isListItem (?Node $n)
 Check whether node is a list item.
 
static isListOrListItem (?Node $n)
 Check whether node is a list or list item.
 
static isNestedInListItem (?Node $n)
 Check whether node is nestee in a list item.
 
static isNestedListOrListItem (?Node $n)
 Check whether node is a nested list or a list item.
 
static isMarkerMeta (Node $n, string $type)
 Check a node to see whether it's a meta with some typeof.
 
static isDiffMarker (?Node $node, ?string $mark=null)
 Check a node to see whether it's a diff marker.
 
static hasElementChild (Node $node)
 Check whether a node has any children that are elements.
 
static hasBlockElementDescendant (Node $node)
 Check if a node has a block-level element descendant.
 
static isIEW (?Node $node)
 Is a node representing inter-element whitespace?
 
static isDocumentFragment (?Node $node)
 Is a node a document fragment?
 
static atTheTop (?Node $node)
 Is a node at the top?
 
static isContentNode (?Node $node)
 Is a node a content node?
 
static firstNonSepChild (Node $node)
 Get the first child element or non-IEW text node, ignoring whitespace-only text nodes, comments, and deleted nodes.
 
static lastNonSepChild (Node $node)
 Get the last child element or non-IEW text node, ignoring whitespace-only text nodes, comments, and deleted nodes.
 
static previousNonSepSibling (Node $node)
 Get the previous non separator sibling node.
 
static nextNonSepSibling (Node $node)
 Get the next non separator sibling node.
 
static numNonDeletedChildNodes (Node $node)
 Return the numbler of non deleted child nodes.
 
static firstNonDeletedChild (Node $node)
 Get the first non-deleted child of node.
 
static lastNonDeletedChild (Node $node)
 Get the last non-deleted child of node.
 
static nextNonDeletedSibling (Node $node)
 Get the next non deleted sibling.
 
static previousNonDeletedSibling (Node $node)
 Get the previous non deleted sibling.
 
static allChildrenAreTextOrComments (Node $node)
 Are all children of this node text or comment nodes?
 
static nodeEssentiallyEmpty (Node $node, bool $strict=false)
 Does node contain nothing or just non-newline whitespace? strict adds the condition that all whitespace is forbidden.
 
static treeHasElement (Node $node, string $tagName, bool $checkRoot=false)
 Check if the dom-subtree rooted at node has an element with tag name 'tagName' By default, the root node is not checked.
 
static isTableTag (Node $node)
 Is node a table tag (table, tbody, td, tr, etc.)?
 
static selectMediaElt (Element $node)
 Returns a media element nested in node
 
static findHttpEquivHeaders (Document $doc)
 Extract http-equiv headers from the HTML, including content-language and vary headers, if present.
 
static extractInlinedContentVersion (Document $doc)
 
static addAttributes (Element $elt, array $attrs)
 Add attributes to a node element.
 
static appendToHead (Document $document, string $tagName, array $attrs=[])
 Create an element in the document head with the given attrs.
 
static getFragmentInnerHTML (DocumentFragment $frag)
 innerHTML and outerHTML are not defined on DocumentFragment.
 
static setFragmentInnerHTML (DocumentFragment $frag, string $html)
 innerHTML and outerHTML are not defined on DocumentFragment.
 
static parseHTMLToFragment (Document $doc, string $html)
 
static isRawTextElement (Node $node)
 
static hasBlockTag (Node $n)
 Is 'n' a block tag, or does the subtree rooted at 'n' have a block tag in it?
 
static attributes ( $element)
 Get an associative array of attributes, suitable for serialization.
 

Detailed Description

DOM utilities for querying the DOM.

This is largely independent of Parsoid although some Parsoid details (diff markers, TokenUtils, inline content version) have snuck in.

Member Function Documentation

◆ addAttributes()

static Wikimedia\Parsoid\Utils\DOMUtils::addAttributes ( Element $elt,
array $attrs )
static

Add attributes to a node element.

Parameters
Element$eltelement
array$attrsattributes

◆ addRel()

static Wikimedia\Parsoid\Utils\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$nodenode
string$reltype

◆ addTypeOf()

static Wikimedia\Parsoid\Utils\DOMUtils::addTypeOf ( Element $node,
string $type )
static

Add a type to the typeof attribute.

This method should almost always be used instead of setAttribute, to ensure we don't overwrite existing typeof information.

Parameters
Element$nodenode
string$typetype

◆ addValueToMultivalAttr()

static Wikimedia\Parsoid\Utils\DOMUtils::addValueToMultivalAttr ( Element $node,
string $attr,
string $value )
static

Add an element to a multivalue attribute (typeof, rel).

This method should almost always be used instead of setAttribute, to ensure we don't overwrite existing multivalue information.

Parameters
Element$node
string$attr
string$value

◆ allChildrenAreTextOrComments()

static Wikimedia\Parsoid\Utils\DOMUtils::allChildrenAreTextOrComments ( Node $node)
static

Are all children of this node text or comment nodes?

Parameters
Node$node
Returns
bool

◆ appendToHead()

static Wikimedia\Parsoid\Utils\DOMUtils::appendToHead ( Document $document,
string $tagName,
array $attrs = [] )
static

Create an element in the document head with the given attrs.

Creates the head element in the document if needed.

Parameters
Document$document
string$tagName
array$attrs
Returns
Element The newly-appended Element

◆ assertElt()

static Wikimedia\Parsoid\Utils\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
?Node$node
Returns
bool Always returns true @phan-assert Element $node

◆ atTheTop()

static Wikimedia\Parsoid\Utils\DOMUtils::atTheTop ( ?Node $node)
static

Is a node at the top?

Parameters
?Node$node
Returns
bool

◆ attributes()

static Wikimedia\Parsoid\Utils\DOMUtils::attributes ( $element)
static

Get an associative array of attributes, suitable for serialization.

Add the xmlns attribute if available, to workaround PHP's surprising behavior with the xmlns attribute: HTML is not an XML document, but various parts of PHP (including our misnamed XMLSerializer) pretend that it is, sort of.

Parameters
Element$element
Returns
string[]
See also
https://phabricator.wikimedia.org/T235295

◆ extractInlinedContentVersion()

static Wikimedia\Parsoid\Utils\DOMUtils::extractInlinedContentVersion ( Document $doc)
static
Parameters
Document$doc
Returns
string|null

◆ findAncestorOfName()

static Wikimedia\Parsoid\Utils\DOMUtils::findAncestorOfName ( Node $node,
string $name )
static

Find an ancestor of $node with nodeName $name.

Parameters
Node$node
string$name
Returns
?Element

◆ findHttpEquivHeaders()

static Wikimedia\Parsoid\Utils\DOMUtils::findHttpEquivHeaders ( Document $doc)
static

Extract http-equiv headers from the HTML, including content-language and vary headers, if present.

Parameters
Document$doc
Returns
array<string,string>

◆ firstNonDeletedChild()

static Wikimedia\Parsoid\Utils\DOMUtils::firstNonDeletedChild ( Node $node)
static

Get the first non-deleted child of node.

Parameters
Node$node
Returns
Node|null

◆ firstNonSepChild()

static Wikimedia\Parsoid\Utils\DOMUtils::firstNonSepChild ( Node $node)
static

Get the first child element or non-IEW text node, ignoring whitespace-only text nodes, comments, and deleted nodes.

Parameters
Node$node
Returns
Node|null

◆ getFragmentInnerHTML()

static Wikimedia\Parsoid\Utils\DOMUtils::getFragmentInnerHTML ( DocumentFragment $frag)
static

innerHTML and outerHTML are not defined on DocumentFragment.

Defined similarly to DOMCompat::getInnerHTML()

Parameters
DocumentFragment$frag
Returns
string

◆ hasBlockElementDescendant()

static Wikimedia\Parsoid\Utils\DOMUtils::hasBlockElementDescendant ( Node $node)
static

Check if a node has a block-level element descendant.

Parameters
Node$node
Returns
bool

◆ hasBlockTag()

static Wikimedia\Parsoid\Utils\DOMUtils::hasBlockTag ( Node $n)
static

Is 'n' a block tag, or does the subtree rooted at 'n' have a block tag in it?

Parameters
Node$n
Returns
bool

◆ hasElementChild()

static Wikimedia\Parsoid\Utils\DOMUtils::hasElementChild ( Node $node)
static

Check whether a node has any children that are elements.

Parameters
Node$node
Returns
bool

◆ hasNameAndTypeOf()

static Wikimedia\Parsoid\Utils\DOMUtils::hasNameAndTypeOf ( Node $n,
string $name,
string $type )
static

Determine whether the node matches the given nodeName and typeof attribute value; the typeof is given as string.

Parameters
Node$n
string$namenode name to test for
string$typeExpected value of "typeof" attribute (literal string)
Returns
bool True if the node matches.

◆ hasNameOrHasAncestorOfName()

static Wikimedia\Parsoid\Utils\DOMUtils::hasNameOrHasAncestorOfName ( Node $node,
string $name )
static

Check whether $node has $name or has an ancestor named $name.

Parameters
Node$node
string$name
Returns
bool

◆ hasNChildren()

static Wikimedia\Parsoid\Utils\DOMUtils::hasNChildren ( Node $node,
int $nchildren,
bool $countDiffMarkers = false )
static

Test the number of children this node has without using DOMNode::$childNodes->count().

This walks the sibling list and so takes O(nchildren) time – so nchildren is expected to be small (say: 0, 1, or 2).

Skips all diff markers by default.

Parameters
Node$node
int$nchildren
bool$countDiffMarkers
Returns
bool

◆ hasRel()

static Wikimedia\Parsoid\Utils\DOMUtils::hasRel ( Node $n,
string $rel )
static

Determine whether the node matches the given rel attribute value.

Parameters
Node$n
string$relExpected value of "rel" attribute, as a literal string.
Returns
bool True if the node matches.

◆ hasTypeOf()

static Wikimedia\Parsoid\Utils\DOMUtils::hasTypeOf ( Node $n,
string $type )
static

Determine whether the node matches the given typeof attribute value.

Parameters
Node$n
string$typeExpected value of "typeof" attribute, as a literal string.
Returns
bool True if the node matches.

◆ hasValueInMultivalAttr()

static Wikimedia\Parsoid\Utils\DOMUtils::hasValueInMultivalAttr ( Node $n,
string $attrName,
string $value )
static

Determine whether the node matches the given attribute value for a multivalued attribute.

Parameters
Node$n
string$attrNamename of the attribute to check (typically 'typeof', 'rel')
string$valueExpected value of $attrName" attribute, as a literal string.
Returns
bool True if the node matches

◆ inSiblingOrder()

static Wikimedia\Parsoid\Utils\DOMUtils::inSiblingOrder ( Node $n1,
Node $n2 )
static

Check whether a node n1 comes before another node n2 in their parent's children list.

Parameters
Node$n1The node you expect to come first.
Node$n2Expected later sibling.
Returns
bool

◆ isAncestorOf()

static Wikimedia\Parsoid\Utils\DOMUtils::isAncestorOf ( Node $n1,
Node $n2 )
static

Check that a node 'n1' is an ancestor of another node 'n2' in the DOM.

Returns true if n1 === n2. $n1 is the suspected ancestor. $n2 The suspected descendant.

Parameters
Node$n1
Node$n2
Returns
bool

◆ isBody()

static Wikimedia\Parsoid\Utils\DOMUtils::isBody ( ?Node $node)
static

Determine whether this is the <body> DOM element.

Parameters
?Node$node
Returns
bool

◆ isContentNode()

static Wikimedia\Parsoid\Utils\DOMUtils::isContentNode ( ?Node $node)
static

Is a node a content node?

Parameters
?Node$node
Returns
bool

◆ isDiffMarker()

static Wikimedia\Parsoid\Utils\DOMUtils::isDiffMarker ( ?Node $node,
?string $mark = null )
static

Check a node to see whether it's a diff marker.

Parameters
?Node$node
?string$mark
Returns
bool

◆ isDocumentFragment()

static Wikimedia\Parsoid\Utils\DOMUtils::isDocumentFragment ( ?Node $node)
static

Is a node a document fragment?

Parameters
?Node$node
Returns
bool

◆ isFormattingElt()

static Wikimedia\Parsoid\Utils\DOMUtils::isFormattingElt ( ?Node $node)
static

Determine whether this is a formatting DOM element.

Parameters
?Node$node
Returns
bool

◆ isFosterablePosition()

static Wikimedia\Parsoid\Utils\DOMUtils::isFosterablePosition ( ?Node $n)
static

Check whether node is in a fosterable position.

Parameters
?Node$n
Returns
bool

◆ isHeading()

static Wikimedia\Parsoid\Utils\DOMUtils::isHeading ( ?Node $n)
static

Check whether node is a heading.

Parameters
?Node$n
Returns
bool

◆ isIEW()

static Wikimedia\Parsoid\Utils\DOMUtils::isIEW ( ?Node $node)
static

Is a node representing inter-element whitespace?

Parameters
?Node$node
Returns
bool

◆ isList()

static Wikimedia\Parsoid\Utils\DOMUtils::isList ( ?Node $n)
static

Check whether node is a list.

Parameters
?Node$n
Returns
bool

◆ isListItem()

static Wikimedia\Parsoid\Utils\DOMUtils::isListItem ( ?Node $n)
static

Check whether node is a list item.

Parameters
?Node$n
Returns
bool

◆ isListOrListItem()

static Wikimedia\Parsoid\Utils\DOMUtils::isListOrListItem ( ?Node $n)
static

Check whether node is a list or list item.

Parameters
?Node$n
Returns
bool

◆ isMarkerMeta()

static Wikimedia\Parsoid\Utils\DOMUtils::isMarkerMeta ( Node $n,
string $type )
static

Check a node to see whether it's a meta with some typeof.

Parameters
Node$n
string$type
Returns
bool

◆ isNestedInListItem()

static Wikimedia\Parsoid\Utils\DOMUtils::isNestedInListItem ( ?Node $n)
static

Check whether node is nestee in a list item.

Parameters
?Node$n
Returns
bool

◆ isNestedListOrListItem()

static Wikimedia\Parsoid\Utils\DOMUtils::isNestedListOrListItem ( ?Node $n)
static

Check whether node is a nested list or a list item.

Parameters
?Node$n
Returns
bool

◆ isQuoteElt()

static Wikimedia\Parsoid\Utils\DOMUtils::isQuoteElt ( ?Node $node)
static

Determine whether this is a quote DOM element.

Parameters
?Node$node
Returns
bool

◆ isRawTextElement()

static Wikimedia\Parsoid\Utils\DOMUtils::isRawTextElement ( Node $node)
static
Parameters
Node$node
Returns
bool

◆ isRemexBlockNode()

static Wikimedia\Parsoid\Utils\DOMUtils::isRemexBlockNode ( ?Node $node)
static
Parameters
?Node$node
Returns
bool

◆ isRemoved()

static Wikimedia\Parsoid\Utils\DOMUtils::isRemoved ( ?Node $node)
static

Determine whether this is a removed DOM node but Node object yet.

Parameters
?Node$node
Returns
bool

◆ isTableTag()

static Wikimedia\Parsoid\Utils\DOMUtils::isTableTag ( Node $node)
static

Is node a table tag (table, tbody, td, tr, etc.)?

Parameters
Node$node
Returns
bool

◆ isWikitextBlockNode()

static Wikimedia\Parsoid\Utils\DOMUtils::isWikitextBlockNode ( ?Node $node)
static
Parameters
?Node$node
Returns
bool

◆ lastNonDeletedChild()

static Wikimedia\Parsoid\Utils\DOMUtils::lastNonDeletedChild ( Node $node)
static

Get the last non-deleted child of node.

Parameters
Node$node
Returns
Node|null

◆ lastNonSepChild()

static Wikimedia\Parsoid\Utils\DOMUtils::lastNonSepChild ( Node $node)
static

Get the last child element or non-IEW text node, ignoring whitespace-only text nodes, comments, and deleted nodes.

Parameters
Node$node
Returns
Node|null

◆ matchMultivalAttr()

static Wikimedia\Parsoid\Utils\DOMUtils::matchMultivalAttr ( Node $n,
string $attrName,
string $valueRe )
static

Determine whether the node matches the given multivalue attribute value.

Parameters
Node$nThe node to test
string$attrNamethe attribute to test (typically 'rel' or 'typeof')
string$valueReRegular expression matching the expected value of the attribute.
Returns
?string The matching attribute value, or null if there is no match.

◆ matchNameAndTypeOf()

static Wikimedia\Parsoid\Utils\DOMUtils::matchNameAndTypeOf ( Node $n,
string $name,
string $typeRe )
static

Determine whether the node matches the given nodeName and attribute value.

Returns true if node name matches and the attribute equals "typeof"

Parameters
Node$nThe node to test
string$nameThe expected nodeName of $n
string$typeReRegular expression matching the expected value of typeof attribute.
Returns
?string The matching typeof value, or null if there is no match.

◆ matchRel()

static Wikimedia\Parsoid\Utils\DOMUtils::matchRel ( Node $n,
string $relRe )
static

Determine whether the node matches the given rel attribute value.

Parameters
Node$nThe node to test
string$relReRegular expression matching the expected value of the rel attribute.
Returns
?string The matching rel value, or null if there is no match.

◆ matchTypeOf()

static Wikimedia\Parsoid\Utils\DOMUtils::matchTypeOf ( Node $n,
string $typeRe )
static

Determine whether the node matches the given typeof attribute value.

Parameters
Node$nThe node to test
string$typeReRegular 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\Utils\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$fromSource node. Children will be removed.
Node$toDestination node. Children of $from will be added here
?Node$beforeNodeAdd the children before this node.

◆ migrateChildrenBetweenDocs()

static Wikimedia\Parsoid\Utils\DOMUtils::migrateChildrenBetweenDocs ( Node $from,
Node $to,
?Node $beforeNode = null )
static

Copy 'from'.childNodes to 'to' adding them before 'beforeNode' 'from' and 'to' belong to different documents.

If 'beforeNode' is null, the nodes are appended at the end.

Parameters
Node$from
Node$to
?Node$beforeNode

◆ nextNonDeletedSibling()

static Wikimedia\Parsoid\Utils\DOMUtils::nextNonDeletedSibling ( Node $node)
static

Get the next non deleted sibling.

Parameters
Node$node
Returns
Node|null

◆ nextNonSepSibling()

static Wikimedia\Parsoid\Utils\DOMUtils::nextNonSepSibling ( Node $node)
static

Get the next non separator sibling node.

Parameters
Node$node
Returns
Node|null

◆ nodeEssentiallyEmpty()

static Wikimedia\Parsoid\Utils\DOMUtils::nodeEssentiallyEmpty ( Node $node,
bool $strict = false )
static

Does node contain nothing or just non-newline whitespace? strict adds the condition that all whitespace is forbidden.

Parameters
Node$node
bool$strict
Returns
bool

◆ numNonDeletedChildNodes()

static Wikimedia\Parsoid\Utils\DOMUtils::numNonDeletedChildNodes ( Node $node)
static

Return the numbler of non deleted child nodes.

Parameters
Node$node
Returns
int

◆ parseHTML()

static Wikimedia\Parsoid\Utils\DOMUtils::parseHTML ( string $html,
bool $validateXMLNames = false )
static

Parse HTML, return the tree.

Parameters
string$html
bool$validateXMLNames
Returns
Document

◆ parseHTMLToFragment()

static Wikimedia\Parsoid\Utils\DOMUtils::parseHTMLToFragment ( Document $doc,
string $html )
static
Parameters
Document$doc
string$html
Returns
DocumentFragment

◆ pathToAncestor()

static Wikimedia\Parsoid\Utils\DOMUtils::pathToAncestor ( Node $node,
?Node $ancestor = null )
static

Build path from a node to its passed-in ancestor.

Doesn't include the ancestor in the returned path.

Parameters
Node$node
?Node$ancestor$ancestor should be an ancestor of $node. If null, we'll walk to the document root.
Returns
Node[]

◆ pathToRoot()

static Wikimedia\Parsoid\Utils\DOMUtils::pathToRoot ( Node $node)
static

Build path from a node to the root of the document.

Parameters
Node$node
Returns
Node[]

◆ pathToSibling()

static Wikimedia\Parsoid\Utils\DOMUtils::pathToSibling ( Node $node,
Node $sibling,
bool $left )
static

Build path from a node to its passed-in sibling.

Return will not include the passed-in sibling.

Parameters
Node$node
Node$sibling
bool$leftindicates whether to go backwards, use previousSibling instead of nextSibling.
Returns
Node[]

◆ previousNonDeletedSibling()

static Wikimedia\Parsoid\Utils\DOMUtils::previousNonDeletedSibling ( Node $node)
static

Get the previous non deleted sibling.

Parameters
Node$node
Returns
Node|null

◆ previousNonSepSibling()

static Wikimedia\Parsoid\Utils\DOMUtils::previousNonSepSibling ( Node $node)
static

Get the previous non separator sibling node.

Parameters
Node$node
Returns
Node|null

◆ removeTypeOf()

static Wikimedia\Parsoid\Utils\DOMUtils::removeTypeOf ( Element $node,
string $type )
static

Remove a type from the typeof attribute.

Parameters
Element$nodenode
string$typetype

◆ selectMediaElt()

static Wikimedia\Parsoid\Utils\DOMUtils::selectMediaElt ( Element $node)
static

Returns a media element nested in node

Parameters
Element$node
Returns
Element|null

◆ setFragmentInnerHTML()

static Wikimedia\Parsoid\Utils\DOMUtils::setFragmentInnerHTML ( DocumentFragment $frag,
string $html )
static

innerHTML and outerHTML are not defined on DocumentFragment.

Parameters
DocumentFragment$frag
string$html

◆ treeHasElement()

static Wikimedia\Parsoid\Utils\DOMUtils::treeHasElement ( Node $node,
string $tagName,
bool $checkRoot = false )
static

Check if the dom-subtree rooted at node has an element with tag name 'tagName' By default, the root node is not checked.

Parameters
Node$nodeThe DOM node whose tree should be checked
string$tagNameTag name to look for
bool$checkRootShould the root be checked?
Returns
bool

◆ visitDOM()

static Wikimedia\Parsoid\Utils\DOMUtils::visitDOM ( Node $node,
callable $handler,
$args )
static

This is a simplified version of the DOMTraverser.

Consider using that before making this more complex.

FIXME: Move to DOMTraverser OR create a new class?

Parameters
Node$node
callable$handler
mixed...$args

The documentation for this class was generated from the following file: