PrototypeElement extends PrototypeTraversal
Tags
Table of Contents
- ancestors() : NodeList
- Collects all of element's ancestor elements and returns them as an array of extended elements.
- childElements() : NodeList
- Collects all of the element's children and returns them as an array of Element.extended elements, in document order.
- cleanWhitespace() : PrototypeNode
- Removes all of element's child text nodes that contain only whitespace. Returns element.
- descendantOf() : bool
- Checks if element is a descendant of ancestor.
- descendants() : NodeList
- Collects all of the element's descendants (its children, their children, etc.) and returns them as an array of extended elements.
- down() : PrototypeTraversal|null
- Returns element's first descendant (or the Nth descendant, if index is specified) that matches expression.
- empty() : bool
- Tests whether element is empty (i.e., contains only whitespace).
- firstDescendant() : PrototypeTraversal|null
- Returns the first child that is an element.
- importNode() : PrototypeNode
- Imports a new node into the document
- insert() : PrototypeElement
- insert_after() : PrototypeElement
- Shortcut for PrototypeElement::insert(['after' => $content])
- insert_before() : PrototypeElement
- Shortcut for PrototypeElement::insert(['before' => $content])
- insert_bottom() : PrototypeElement
- Shortcut for PrototypeElement::insert(['bottom' => $content])
- insert_top() : PrototypeElement
- Shortcut for PrototypeElement::insert(['top' => $content])
- inspect() : string
- Returns the debug-oriented string representation of element.
- match() : bool
- Checks if element matches the given CSS selector.
- name() : string
- Returns the node name (convenience method)
- next() : PrototypeTraversal|null
- Returns element's first following sibling (or the Nth, if index is specified) that matches expression.
- nextSiblings() : NodeList
- Collects all of element's next siblings and returns them as an Array of elements.
- previous() : PrototypeTraversal|null
- Returns element's first previous sibling (or the Nth, if index is specified) that matches expression.
- previousSiblings() : NodeList
- Collects all of element's previous siblings and returns them as an Array of elements.
- purge() : PrototypeNode
- Removes all child elements from the current element (not to confuse with the prototype method of the same name)
- recursivelyCollect() : NodeList
- Recursively collects elements whose relationship to element is specified by property.
- recursivelyFind() : PrototypeTraversal|DOMNode|null
- removeNode() : PrototypeNode
- Completely removes element from the document and returns it.
- replace() : PrototypeNode
- Replaces element itself with newContent and returns element.
- select() : NodeList
- This method is very similar to $$ but can be used within the context of one element, rather than the whole document.
- siblings() : NodeList
- Collects all of element's siblings and returns them as an Array of elements.
- tag() : string|null
- Returns the element tag name (convenience method) or null if the property doesn't exist
- up() : PrototypeTraversal|null
- Returns element's first ancestor (or the Nth ancestor, if index is specified) that matches expression.
- update() : PrototypeElement
- value() : string
- Returns the node value, optionally trims whitespace (default)
- wrap() : PrototypeElement
Methods
ancestors()
Collects all of element's ancestor elements and returns them as an array of extended elements.
public
ancestors() : NodeList
Tags
Return values
NodeList —childElements()
Collects all of the element's children and returns them as an array of Element.extended elements, in document order.
public
childElements([int $nodeType = null ]) : NodeList
The first entry in the array is the topmost child of element, the next is the child after that, etc.
Parameters
- $nodeType : int = null
Tags
Return values
NodeList —cleanWhitespace()
Removes all of element's child text nodes that contain only whitespace. Returns element.
public
cleanWhitespace() : PrototypeNode
Tags
Return values
PrototypeNode —descendantOf()
Checks if element is a descendant of ancestor.
public
descendantOf(DOMNode $ancestor) : bool
Parameters
- $ancestor : DOMNode
Tags
Return values
bool —descendants()
Collects all of the element's descendants (its children, their children, etc.) and returns them as an array of extended elements.
public
descendants() : NodeList
Tags
Return values
NodeList —down()
Returns element's first descendant (or the Nth descendant, if index is specified) that matches expression.
public
down([int|string|array<string|int, mixed>|null $expression = null ][, int|null $index = null ]) : PrototypeTraversal|null
If no expression is provided, all descendants are considered. If no descendant matches these criteria, null is returned.
Parameters
- $expression : int|string|array<string|int, mixed>|null = null
- $index : int|null = null
Tags
Return values
PrototypeTraversal|null —empty()
Tests whether element is empty (i.e., contains only whitespace).
public
empty() : bool
Tags
Return values
bool —firstDescendant()
Returns the first child that is an element.
public
firstDescendant() : PrototypeTraversal|null
Tags
Return values
PrototypeTraversal|null —importNode()
Imports a new node into the document
public
importNode(PrototypeNode $newNode) : PrototypeNode
Parameters
- $newNode : PrototypeNode
Return values
PrototypeNode —insert()
public
insert(string|array<string|int, mixed>|DOMNode|DOMNodeList|PrototypeElement $content) : PrototypeElement
Parameters
- $content : string|array<string|int, mixed>|DOMNode|DOMNodeList|PrototypeElement
Tags
Return values
PrototypeElement —insert_after()
Shortcut for PrototypeElement::insert(['after' => $content])
public
insert_after(PrototypeElement $node) : PrototypeElement
Parameters
- $node : PrototypeElement
Return values
PrototypeElement —insert_before()
Shortcut for PrototypeElement::insert(['before' => $content])
public
insert_before(PrototypeElement $node[, PrototypeElement $refNode = null ]) : PrototypeElement
Parameters
- $node : PrototypeElement
- $refNode : PrototypeElement = null
Return values
PrototypeElement —insert_bottom()
Shortcut for PrototypeElement::insert(['bottom' => $content])
public
insert_bottom(PrototypeElement $node) : PrototypeElement
Parameters
- $node : PrototypeElement
Return values
PrototypeElement —insert_top()
Shortcut for PrototypeElement::insert(['top' => $content])
public
insert_top(PrototypeElement $node) : PrototypeElement
Parameters
- $node : PrototypeElement
Return values
PrototypeElement —inspect()
Returns the debug-oriented string representation of element.
public
inspect([bool $xml = null ]) : string
Parameters
- $xml : bool = null
Tags
Return values
string —match()
Checks if element matches the given CSS selector.
public
match(string $selector) : bool
Parameters
- $selector : string
Tags
Return values
bool —name()
Returns the node name (convenience method)
public
name() : string
Return values
string —next()
Returns element's first following sibling (or the Nth, if index is specified) that matches expression.
public
next([int|string|array<string|int, mixed>|null $expression = null ][, int|null $index = null ]) : PrototypeTraversal|null
If no expression is provided, all following siblings are considered. If none matches these criteria, null is returned.
Parameters
- $expression : int|string|array<string|int, mixed>|null = null
- $index : int|null = null
Tags
Return values
PrototypeTraversal|null —nextSiblings()
Collects all of element's next siblings and returns them as an Array of elements.
public
nextSiblings() : NodeList
Tags
Return values
NodeList —previous()
Returns element's first previous sibling (or the Nth, if index is specified) that matches expression.
public
previous([int|string|array<string|int, mixed>|null $expression = null ][, int|null $index = null ]) : PrototypeTraversal|null
If no expression is provided, all previous siblings are considered. If none matches these criteria, null is returned.
Parameters
- $expression : int|string|array<string|int, mixed>|null = null
- $index : int|null = null
Tags
Return values
PrototypeTraversal|null —previousSiblings()
Collects all of element's previous siblings and returns them as an Array of elements.
public
previousSiblings() : NodeList
Tags
Return values
NodeList —purge()
Removes all child elements from the current element (not to confuse with the prototype method of the same name)
public
purge() : PrototypeNode
Return values
PrototypeNode —recursivelyCollect()
Recursively collects elements whose relationship to element is specified by property.
public
recursivelyCollect(string $property[, int $maxLength = null ][, int $nodeType = null ]) : NodeList
property has to be a property of element that points to a single DOM node (e.g., nextSibling or parentNode).
Parameters
- $property : string
- $maxLength : int = null
- $nodeType : int = null
Tags
Return values
NodeList —recursivelyFind()
public
recursivelyFind([string $selector = null ][, int $index = null ][, string $property = null ][, int $nodeType = XML_ELEMENT_NODE ]) : PrototypeTraversal|DOMNode|null
Parameters
- $selector : string = null
- $index : int = null
- $property : string = null
- $nodeType : int = XML_ELEMENT_NODE
Tags
Return values
PrototypeTraversal|DOMNode|null —removeNode()
Completely removes element from the document and returns it.
public
removeNode() : PrototypeNode
Tags
Return values
PrototypeNode —replace()
Replaces element itself with newContent and returns element.
public
replace(PrototypeNode $newNode) : PrototypeNode
Parameters
- $newNode : PrototypeNode
Tags
Return values
PrototypeNode —select()
This method is very similar to $$ but can be used within the context of one element, rather than the whole document.
public
select([array<string|int, mixed> $selectors = null ]) : NodeList
The supported CSS syntax is identical, so please refer to the $$ docs for details.
Parameters
- $selectors : array<string|int, mixed> = null
Tags
Return values
NodeList —siblings()
Collects all of element's siblings and returns them as an Array of elements.
public
siblings() : NodeList
Tags
Return values
NodeList —tag()
Returns the element tag name (convenience method) or null if the property doesn't exist
public
tag() : string|null
Return values
string|null —up()
Returns element's first ancestor (or the Nth ancestor, if index is specified) that matches expression.
public
up([int|string|array<string|int, mixed>|null $expression = null ][, int|null $index = null ]) : PrototypeTraversal|null
If no expression is provided, all ancestors are considered. If no ancestor matches these criteria, null is returned.
Parameters
- $expression : int|string|array<string|int, mixed>|null = null
- $index : int|null = null
Tags
Return values
PrototypeTraversal|null —update()
public
update(string|DOMNode|DOMNodeList $content) : PrototypeElement
Parameters
- $content : string|DOMNode|DOMNodeList
Tags
Return values
PrototypeElement —value()
Returns the node value, optionally trims whitespace (default)
public
value([bool $trimmed = true ]) : string
Parameters
- $trimmed : bool = true
Return values
string —wrap()
public
wrap(PrototypeElement $wrapper) : PrototypeElement
Parameters
- $wrapper : PrototypeElement