Dodo
DOm DOcument implementation
Loading...
Searching...
No Matches
Wikimedia\Dodo\Element Class Reference
+ Inheritance diagram for Wikimedia\Dodo\Element:

Public Member Functions

static callable(Element,?string,?string)(string $localName) void __construct (Document $nodeDocument, string $lname, ?string $ns, ?string $prefix=null)
 Fetch the appropriate attribute change handler for a change to the attribute named $localName.
 
int getNodeType ()
 Return the node type enumeration for this node.
See also
https://dom.spec.whatwg.org/#dom-node-nodetype
Returns
int

 
string getNodeName ()
 Return the nodeName for this node.
See also
https://dom.spec.whatwg.org/#dom-node-nodename
Returns
string

 
NamedNodeMap getAttributes ()
 
string getPrefix ()
 
string getLocalName ()
 
string getNamespaceURI ()
 
string getTagName ()
 
string getInnerHTML ()
 
string getOuterHTML ()
 
 setIdAttribute (string $qualifiedName, bool $isId)
 
 _xmlSerialize (?string $namespace, NamespacePrefixMap $prefixMap, int &$prefixIndex, array $options, array &$markup)
 XML serialize the given node.This is overridden in subclasses. Note that this is effectively "outerHTML", due to a spec inconsistency: https://github.com/w3c/DOM-Parsing/issues/28 .
See also
https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization
Parameters
?string$namespace
NamespacePrefixMap$prefixMap
int&$prefixIndex
array$options
string[]&$markupaccumulator for the result

 
string getAttribute (string $qname)
 Fetch the value of an attribute with the given qualified name.
 
 setAttribute (string $qname, string $value)
 Set the value of first attribute with a particular qualifiedName.
 
 _setAttribute (string $qname, string $value)
 Internal version of ::setAttribute() which bypasses checks and lowercasing; used by Remex when tree building.
 
 removeAttribute (string $qname)
 Remove the first attribute given a particular qualifiedName.
 
bool hasAttribute (string $qname)
 Test Element for attribute with the given qualified name.
 
bool toggleAttribute (string $qname, ?bool $force=null)
 Toggle the first attribute with the given qualified name.
 
string getAttributeNS (?string $ns, string $lname)
 Fetch value of attribute with the given namespace and localName.
 
 setAttributeNS (?string $ns, string $qname, string $value)
 Set value of attribute with a particular namespace and localName.
 
 _setAttributeNS (?string $ns, ?string $prefix, string $lname, string $value)
 Internal version of ::setAttributeNS which bypasses checks and prefix parsing; used by Remex when tree building.
 
 removeAttributeNS (?string $ns, string $lname)
 Remove attribute given a particular namespace and localName.
 
bool hasAttributeNS (?string $ns, string $lname)
 Test Element for attribute with the given namespace and localName.
 
Attr getAttributeNode (string $qname)
 Fetch the Attr node with the given qualifiedName.
 
Attr setAttributeNode ( $attr)
 Add an Attr node to an Element node.
 
Attr removeAttributeNode ( $attr)
 Remove the given attribute node from this Element.
 
Attr getAttributeNodeNS (?string $ns, string $lname)
 Fetch the Attr node with the given namespace and localName.
 
Attr setAttributeNodeNS ( $attr)
 Add a namespace-aware Attr node to an Element node.
 
bool hasAttributes ()
 Test whether this Element has any attributes.
 
array getAttributeNames ()
 Fetch the qualified names of all attributes on this Element.
 
mixed null getClassList ()
 
bool matches (string $selectors)
 
bool webkitMatchesSelector (string $selectors)
 
Element closest (string $selectors)
 
bool _isHTMLElement ()
 Calls isHTMLDocument() on ownerDocument.
 
Element _nextElement (?Element $root)
 Return the next element, in source order, after this one or null if there are no more.
 
HTMLCollection getElementsByTagName (string $lname)
 
HTMLCollection getElementsByClassName (string $names)
 
array< Element_getElementsById (string $id)
 This is a non-standard Dodo extension that interfaces with the Zest CSS selector library to allow quick lookup by ID even if there are multiple nodes in the document with the same ID.
 
static callable(Element)(string $lname) static callable(Element)(string $lname) HTMLCollection getElementsByTagNameNS (?string $ns, string $lname)
 
- Public Member Functions inherited from Wikimedia\Dodo\ContainerNode
 __construct (Document $nodeDocument)
 
bool hasChildNodes ()
 Return true iff there are children of this node.
 
int _length ()
 
See also
https://dom.spec.whatwg.org/#concept-node-length
Returns
int The length of this node.

 
bool _empty ()
 
See also
https://dom.spec.whatwg.org/#concept-node-empty
Returns
bool Whether this node is considered empty.

 
NodeList getChildNodes ()
 Keeping child nodes as an array makes insertion/removal of nodes quite expensive.
 
Node getFirstChild ()
 Be careful to use this method in most cases rather than directly accessing _firstChildOrChildren.
 
Node getLastChild ()
 This should be overridden in ContainerNode and Leaf.
 
string getTextContent ()
 Generic implementation of ::getTextContent to be used by Element and DocumentFragment (but not Document!).
 
 setTextContent (?string $value)
 Generic implementation of ::setTextContent to be used by Element and DocumentFragment (but not Document!).
 
- Public Member Functions inherited from Wikimedia\Dodo\Node
string getNodeValue ()
 Return the value for this node.
 
 setNodeValue (?string $val)
 
Document getOwnerDocument ()
 The ownerDocument getter steps are to return null, if this is a document; otherwise this’s node document.
 
Node getParentNode ()
 Nodes might not have a parentNode.
 
Element getParentElement ()
 This value is the same as parentNode, except it puts an extra condition, that the parentNode must be an Element.
 
Wikimedia IDLeDOM Node getRootNode ($options=null)
 Return this' shadow-including root if options['composed'] is true; otherwise return this' root.
 
Node getPreviousSibling ()
 
Node getNextSibling ()
 
 _roothook ()
 <script> elements need to know when they're inserted into the document.
 
Node insertBefore ($node, $refNode=null)
 Insert $node as a child of $this, and insert it before $refChild in the document order.
 
 appendChild ( $node)
 
Node _unsafeAppendChild (Node $node)
 Does not check for insertion validity.
 
Node replaceChild ( $new, $old)
 
Node removeChild ( $node)
 
 normalize ()
 Puts $this and the entire subtree rooted at $this into "normalized" form.
 
int compareDocumentPosition ( $that)
 
bool contains ( $node)
 
bool isSameNode ( $node)
 
bool isEqualNode ( $node)
 Determine whether this node and $other are equal.
 
Node cloneNode (bool $deep=false)
 Clone this Node.
 
string lookupPrefix (?string $ns)
 Return DOMString containing prefix for given namespace URI.
 
string lookupNamespaceURI (?string $prefix)
 Return DOMString containing namespace URI for a given prefix.
 
bool isDefaultNamespace (?string $ns)
 Determine whether this is the default namespace.
 
string getNodePath ()
 Get an XPath for a node.
 
 _resetNodeDocument (Document $doc)
 Set the ownerDocument reference on a subtree rooted at $this.
 
bool getIsConnected ()
 Determine whether this Node is rooted (belongs to the tree rooted at the node document).
 
int _getSiblingIndex ()
 The index of this Node in its parent's childNodes list.
 
int _lastModTime ()
 Return the lastModTime value for this node.
 
 _modify ()
 Increment the owner document's modclock [and use the new value to update the lastModTime value for this node and all of its ancestors.
 
 _htmlSerialize (array &$result, array $options)
 Convert the children of a node to an HTML string.
 
mixed getExtensionData (string $key, $defaultValue=null)
 Get "extension data" associate with this node, using the given $key.
 
 setExtensionData (string $key, $value)
 Set "extension data" associate with this node, using the given $key.
 
- Public Member Functions inherited from Wikimedia::IDLeDOM::EventTarget
void addEventListener (string $type, $callback, $options=null)
 
void removeEventListener (string $type, $callback, $options=null)
 
bool dispatchEvent ( $event)
 
- Public Member Functions inherited from Wikimedia::IDLeDOM::Node
string getBaseURI ()
 
- Public Member Functions inherited from Wikimedia::IDLeDOM::Element
string getId ()
 
 setId (string $val)
 
string getClassName ()
 
 setClassName (string $val)
 
 setClassList (string $val)
 
string getSlot ()
 
 setSlot (string $val)
 
ShadowRoot attachShadow ( $init)
 
ShadowRoot null getShadowRoot ()
 
Wikimedia IDLeDOM Element null insertAdjacentElement (string $where, $element)
 
void insertAdjacentText (string $where, string $data)
 
 setOuterHTML (?string $val)
 
void insertAdjacentHTML (string $position, string $text)
 
void setIdAttributeNode ( $attr, bool $isId)
 
void setIdAttributeNS (string $namespace, string $qualifiedName, bool $isId)
 
- Public Member Functions inherited from Wikimedia::IDLeDOM::ChildNode
void before (... $nodes)
 
void after (... $nodes)
 
void replaceWith (... $nodes)
 
void remove ()
 
- Public Member Functions inherited from Wikimedia::IDLeDOM::InnerHTML
 setInnerHTML (?string $val)
 
- Public Member Functions inherited from Wikimedia::IDLeDOM::NonDocumentTypeChildNode
Element null getPreviousElementSibling ()
 
Element null getNextElementSibling ()
 
- Public Member Functions inherited from Wikimedia::IDLeDOM::ParentNode
HTMLCollection getChildren ()
 
Element null getFirstElementChild ()
 
Element null getLastElementChild ()
 
int getChildElementCount ()
 
void prepend (... $nodes)
 
void append (... $nodes)
 
void replaceChildren (... $nodes)
 
Element null querySelector (string $selectors)
 
NodeList querySelectorAll (string $selectors)
 
- Public Member Functions inherited from Wikimedia::IDLeDOM::Slottable
HTMLSlotElement null getAssignedSlot ()
 

Public Attributes

NamedNodeMap $_attributes = null
 Attribute storage; null if no attributes.
 
- Public Attributes inherited from Wikimedia\Dodo\ContainerNode
Node NodeList null $_firstChildOrChildren
 The first child (if we're using the linked list representation), or a NodeList (if we're using the array of children), or null (if there are no children).
 
- Public Attributes inherited from Wikimedia\Dodo\Node
Document $_nodeDocument
 The document this node is associated to.
 
Node null $_parentNode
 should be considered read-only
 
Node $_nextSibling
 The sibling list is stored as a circular linked list: the node "before" the first sibling is the last sibling, and the node "after" the last sibling is the first sibling.
 
Node $_previousSibling
 
int $_documentIndex = null
 DEVELOPERS NOTE: An index is assigned when a node is added to a Document (becomes rooted).
 
int $_cachedSiblingIndex = null
 DEVELOPERS NOTE: An index is assigned on INSERTION.
 

Static Public Attributes

static array< string, callable > null $_attributeChangeHandlers = null
 A registry of handlers for changes to specific attributes.
 

Protected Member Functions

 _setMissingProp (string $prop, $value)
 Implement _setMissingProp to allow $_classList to be a dynamic property.
 
Element _subclassCloneNodeShallow ()
 
bool _subclassIsEqualNode (Node $node)
 Delegated subclass method called by Node::isEqualNode()
Parameters
Node$node
Returns
bool

 
- Protected Member Functions inherited from Wikimedia\Dodo\Node
 _getMissingProp (string $name)
 

Constructor & Destructor Documentation

◆ __construct()

static callable(Element,?string,?string)(string $localName) void Wikimedia\Dodo\Element::__construct ( Document $nodeDocument,
string $lname,
?string $ns,
?string $prefix = null )

Fetch the appropriate attribute change handler for a change to the attribute named $localName.

Parameters
string$localName
Returns
?callable(Element,?string,?string):void Element constructor
Parameters
Document$nodeDocument
string$lname
?string$ns
?string$prefix
Returns
void

Member Function Documentation

◆ _getElementsById()

array< Element > Wikimedia\Dodo\Element::_getElementsById ( string $id)

This is a non-standard Dodo extension that interfaces with the Zest CSS selector library to allow quick lookup by ID even if there are multiple nodes in the document with the same ID.

Parameters
string$id
Returns
array<Element>

◆ _isHTMLElement()

bool Wikimedia\Dodo\Element::_isHTMLElement ( )

Calls isHTMLDocument() on ownerDocument.

Returns
bool

◆ _nextElement()

Element Wikimedia\Dodo\Element::_nextElement ( ?Element $root)

Return the next element, in source order, after this one or null if there are no more.

If root element is specified, then don't traverse beyond its subtree.

This is not a DOM method, but is convenient for lazy traversals of the tree.

Parameters
?Element$root
Returns
?Element

◆ _setAttribute()

Wikimedia\Dodo\Element::_setAttribute ( string $qname,
string $value )

Internal version of ::setAttribute() which bypasses checks and lowercasing; used by Remex when tree building.

Parameters
string$qname
string$value

◆ _setAttributeNS()

Wikimedia\Dodo\Element::_setAttributeNS ( ?string $ns,
?string $prefix,
string $lname,
string $value )

Internal version of ::setAttributeNS which bypasses checks and prefix parsing; used by Remex when tree building.

Parameters
?string$ns
?string$prefix
string$lname
string$value

◆ _setMissingProp()

Wikimedia\Dodo\Element::_setMissingProp ( string $prop,
$value )
protected

Implement _setMissingProp to allow $_classList to be a dynamic property.

Very few instances of Element will need to allocate this property.

Parameters
string$propthe name of the property requested
mixed$valuethe value to set

Reimplemented from Wikimedia\Dodo\Node.

◆ _subclassCloneNodeShallow()

Element Wikimedia\Dodo\Element::_subclassCloneNodeShallow ( )
protected
Returns
Element

Reimplemented from Wikimedia\Dodo\Node.

◆ _subclassIsEqualNode()

bool Wikimedia\Dodo\Element::_subclassIsEqualNode ( Node $node)
protected

Delegated subclass method called by Node::isEqualNode()

Parameters
Node$node
Returns
bool

Reimplemented from Wikimedia\Dodo\Node.

◆ _xmlSerialize()

Wikimedia\Dodo\Element::_xmlSerialize ( ?string $namespace,
NamespacePrefixMap $prefixMap,
int & $prefixIndex,
array $options,
array & $markup )

XML serialize the given node.This is overridden in subclasses. Note that this is effectively "outerHTML", due to a spec inconsistency: https://github.com/w3c/DOM-Parsing/issues/28 .

See also
https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization
Parameters
?string$namespace
NamespacePrefixMap$prefixMap
int&$prefixIndex
array$options
string[]&$markupaccumulator for the result

Reimplemented from Wikimedia\Dodo\Node.

◆ closest()

Element Wikimedia\Dodo\Element::closest ( string $selectors)
Parameters
string$selectors
Returns
?Element

Implements Wikimedia::IDLeDOM::Element.

◆ getAttribute()

string Wikimedia\Dodo\Element::getAttribute ( string $qname)

Fetch the value of an attribute with the given qualified name.

Parameters
string$qnameThe attribute's qualifiedName
Returns
?string the value of the attribute

Implements Wikimedia::IDLeDOM::Element.

◆ getAttributeNames()

array Wikimedia\Dodo\Element::getAttributeNames ( )

Fetch the qualified names of all attributes on this Element.

spec DOM-LS

NOTE The names are not guaranteed to be unique.

Returns
array of strings, or empty array if no attributes.

Implements Wikimedia::IDLeDOM::Element.

◆ getAttributeNode()

Attr Wikimedia\Dodo\Element::getAttributeNode ( string $qname)

Fetch the Attr node with the given qualifiedName.

spec DOM-LS

Parameters
string$qnameThe attribute's qualified name
Returns
?Attr the attribute node, or NULL

Implements Wikimedia::IDLeDOM::Element.

◆ getAttributeNodeNS()

Attr Wikimedia\Dodo\Element::getAttributeNodeNS ( ?string $ns,
string $lname )

Fetch the Attr node with the given namespace and localName.

spec DOM-LS

Parameters
?string$nsThe attribute's local name
string$lnameThe attribute's local name
Returns
?Attr the attribute node, or NULL

Implements Wikimedia::IDLeDOM::Element.

◆ getAttributeNS()

string Wikimedia\Dodo\Element::getAttributeNS ( ?string $ns,
string $lname )

Fetch value of attribute with the given namespace and localName.

spec DOM-LS

Parameters
?string$nsThe attribute's namespace
string$lnameThe attribute's local name
Returns
?string the value of the attribute

Implements Wikimedia::IDLeDOM::Element.

◆ getAttributes()

NamedNodeMap Wikimedia\Dodo\Element::getAttributes ( )
Returns
NamedNodeMap

Implements Wikimedia::IDLeDOM::Element.

◆ getClassList()

mixed null Wikimedia\Dodo\Element::getClassList ( )
Returns
mixed|null

Implements Wikimedia::IDLeDOM::Element.

◆ getElementsByClassName()

HTMLCollection Wikimedia\Dodo\Element::getElementsByClassName ( string $names)
Parameters
string$names
Returns
HTMLCollection

Implements Wikimedia::IDLeDOM::Element.

◆ getElementsByTagName()

HTMLCollection Wikimedia\Dodo\Element::getElementsByTagName ( string $lname)
Parameters
string$lname
Returns
HTMLCollection

Implements Wikimedia::IDLeDOM::Element.

◆ getElementsByTagNameNS()

static callable(Element)(string $lname) static callable(Element)(string $lname) HTMLCollection Wikimedia\Dodo\Element::getElementsByTagNameNS ( ?string $ns,
string $lname )
Parameters
string$lname
Returns
callable(Element):bool
Parameters
string$lname
Returns
callable(Element):bool
Parameters
string | null$ns
string$lname
Returns
HTMLCollection

Implements Wikimedia::IDLeDOM::Element.

◆ getInnerHTML()

string Wikimedia\Dodo\Element::getInnerHTML ( )

◆ getLocalName()

string Wikimedia\Dodo\Element::getLocalName ( )

◆ getNamespaceURI()

string Wikimedia\Dodo\Element::getNamespaceURI ( )

◆ getNodeName()

string Wikimedia\Dodo\Element::getNodeName ( )
final

Return the nodeName for this node.

See also
https://dom.spec.whatwg.org/#dom-node-nodename
Returns
string

Reimplemented from Wikimedia\Dodo\Node.

◆ getNodeType()

int Wikimedia\Dodo\Element::getNodeType ( )
final

Return the node type enumeration for this node.

See also
https://dom.spec.whatwg.org/#dom-node-nodetype
Returns
int

Reimplemented from Wikimedia\Dodo\Node.

◆ getOuterHTML()

string Wikimedia\Dodo\Element::getOuterHTML ( )

◆ getPrefix()

string Wikimedia\Dodo\Element::getPrefix ( )

◆ getTagName()

string Wikimedia\Dodo\Element::getTagName ( )
final

◆ hasAttribute()

bool Wikimedia\Dodo\Element::hasAttribute ( string $qname)

Test Element for attribute with the given qualified name.

spec DOM-LS

Parameters
string$qnameQualified name of attribute
Returns
bool

Implements Wikimedia::IDLeDOM::Element.

◆ hasAttributeNS()

bool Wikimedia\Dodo\Element::hasAttributeNS ( ?string $ns,
string $lname )

Test Element for attribute with the given namespace and localName.

spec DOM-LS

Parameters
?string$nsthe namespace
string$lnamethe localName
Returns
bool

Implements Wikimedia::IDLeDOM::Element.

◆ hasAttributes()

bool Wikimedia\Dodo\Element::hasAttributes ( )

Test whether this Element has any attributes.

spec DOM-LS

Returns
bool

Implements Wikimedia::IDLeDOM::Element.

◆ matches()

bool Wikimedia\Dodo\Element::matches ( string $selectors)
Parameters
string$selectors
Returns
bool

Implements Wikimedia::IDLeDOM::Element.

◆ removeAttribute()

Wikimedia\Dodo\Element::removeAttribute ( string $qname)

Remove the first attribute given a particular qualifiedName.

spec DOM-LS

Parameters
string$qname

Implements Wikimedia::IDLeDOM::Element.

◆ removeAttributeNode()

Attr Wikimedia\Dodo\Element::removeAttributeNode ( $attr)

Remove the given attribute node from this Element.

spec DOM-LS

Implements Wikimedia::IDLeDOM::Element.

◆ removeAttributeNS()

Wikimedia\Dodo\Element::removeAttributeNS ( ?string $ns,
string $lname )

Remove attribute given a particular namespace and localName.

spec DOM-LS

Implements Wikimedia::IDLeDOM::Element.

◆ setAttribute()

Wikimedia\Dodo\Element::setAttribute ( string $qname,
string $value )

Set the value of first attribute with a particular qualifiedName.

spec DOM-LS

NOTES Per spec, $value is not a string, but the string value of whatever is passed.

TODO: DRY with this and setAttributeNS?

Implements Wikimedia::IDLeDOM::Element.

◆ setAttributeNode()

Attr Wikimedia\Dodo\Element::setAttributeNode ( $attr)

Add an Attr node to an Element node.

Implements Wikimedia::IDLeDOM::Element.

◆ setAttributeNodeNS()

Attr Wikimedia\Dodo\Element::setAttributeNodeNS ( $attr)

Add a namespace-aware Attr node to an Element node.

Parameters
IAttr$attr
Returns
?Attr

Implements Wikimedia::IDLeDOM::Element.

◆ setAttributeNS()

Wikimedia\Dodo\Element::setAttributeNS ( ?string $ns,
string $qname,
string $value )

Set value of attribute with a particular namespace and localName.

spec DOM-LS

NOTES Per spec, $value is not a string, but the string value of whatever is passed.

Implements Wikimedia::IDLeDOM::Element.

◆ setIdAttribute()

Wikimedia\Dodo\Element::setIdAttribute ( string $qualifiedName,
bool $isId )

◆ toggleAttribute()

bool Wikimedia\Dodo\Element::toggleAttribute ( string $qname,
?bool $force = null )

Toggle the first attribute with the given qualified name.

spec DOM-LS

Parameters
string$qnamequalified name
bool | null$forcewhether to set if no attribute exists
Returns
bool whether we set or removed an attribute

Implements Wikimedia::IDLeDOM::Element.

◆ webkitMatchesSelector()

bool Wikimedia\Dodo\Element::webkitMatchesSelector ( string $selectors)
Parameters
string$selectors
Returns
bool

Implements Wikimedia::IDLeDOM::Element.


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