Dodo
DOm DOcument implementation
Loading...
Searching...
No Matches
Wikimedia\Dodo\Attr Class Reference

The Attr class represents a single attribute node. More...

+ Inheritance diagram for Wikimedia\Dodo\Attr:

Public Member Functions

 __construct (Document $nodeDocument, ?Element $ownerElement, string $localName, ?string $prefix=null, ?string $namespaceURI=null, string $value="")
 
int getNodeType ()
 
string getNodeName ()
 
string getNodeValue ()
 Return the value for this node.
See also
https://dom.spec.whatwg.org/#dom-node-nodevalue
Returns
?string

 
 setNodeValue (?string $value)
 
string getNamespaceURI ()
 
bool getSpecified ()
 
Element getOwnerElement ()
 
string getPrefix ()
 
string getLocalName ()
 
string getName ()
 
string getValue ()
 
 setValue (string $value=null)
 
 _handleAttributeChanges (?Element $elem, ?string $oldValue, ?string $newValue, bool $rootChange=false)
 
string getTextContent ()
 Return the textContent for this node.
See also
https://dom.spec.whatwg.org/#dom-node-textcontent
Returns
?string

 
 setTextContent (?string $val)
 
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.

 
 _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

 
- Public Member Functions inherited from Wikimedia\Dodo\Leaf
bool hasChildNodes ()
 
Node getFirstChild ()
 This should be overridden in ContainerNode and Leaf.
 
Node getLastChild ()
 This should be overridden in ContainerNode and Leaf.
 
Node insertBefore ( $node, $refChild=null)
 Insert $node as a child of $this, and insert it before $refChild in the document order.spec DOM-LSTHINGS TO KNOW FROM THE SPEC:
  1. If $node already exists in this Document, this function moves it from its current position to its new position ('move' means 'remove' followed by 're-insert').
  2. If $refNode is NULL, then $node is added to the end of the list of children of $this. In other words, insertBefore($node, NULL) is equivalent to appendChild($node).
  3. If $node is a DocumentFragment, the children of the DocumentFragment are moved into the child list of $this, and the empty DocumentFragment is returned.
THINGS TO KNOW IN LIFE:Despite its weird syntax (blame the spec), this is a real workhorse, used to implement all of the non-replacing insertion mutations.
Parameters
INode$nodeTo be inserted
?INode$refNodeChild of this node before which to insert $node
Returns
Node Newly inserted Node or empty DocumentFragment
Exceptions
DOMException"HierarchyRequestError" or "NotFoundError"

 
Node replaceChild ( $node, $refChild)
 
Node removeChild ( $node)
 
 _removeChildren ()
 
NodeList getChildNodes ()
 This should be overridden in ContainerNode and Leaf.
 
- Public Member Functions inherited from Wikimedia\Dodo\Node
 __construct (Document $nodeDocument)
 Create a Node whose node document is the given $nodeDocument.
 
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.
 
 appendChild ( $node)
 
Node _unsafeAppendChild (Node $node)
 Does not check for insertion validity.
 
 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 Attributes

Element null $_ownerElement = null
 Should be considered readonly.
 
- 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.
 

Protected Member Functions

mixed _getMissingProp (string $name)
 HACK! For compatibilty with W3C test suite, which assumes that an access to 'attributes' will return null.
 
Attr _subclassCloneNodeShallow ()
 Delegated from Node.
 
- Protected Member Functions inherited from Wikimedia\Dodo\Node
bool _subclassIsEqualNode (Node $node)
 Delegated subclass method called by Node::isEqualNode()
 
 _setMissingProp (string $name, $value)
 

Protected Attributes

string null $_namespaceURI = null
 Should be considered readonly, if a string its non-empty.
 
string null $_prefix = null
 Should be considered readonly, if a string its non-empty.
 
string $_localName = ''
 Should be considered readonly, always non-empty.
 
string $_name = ''
 Should be considered readonly, always non-empty.
 
string $_value = ''
 

Detailed Description

The Attr class represents a single attribute node.

NOTE The definition of the Attr class has undergone some changes in recent revisions of the DOM spec.

 DOM-2: Introduced namespaces, and the properties 'namespaceURI',
        'localName', and 'prefix' were defined on the Node class.
        As a subclass of Node, Attr inherited these.

 DOM-4: Attr was no longer classified as a Node. The properties
        'namespaceURI', 'localName', and 'prefix' were removed
        from the Node class. They were now defined on the Attr
        class itself, as well as on the Element class, which
        remained a subclass of Node.

 DOM-LS: Attr was re-classified as a Node, but the properties
         'namespaceURI', 'localName', and 'prefix' remained on
         the Attr class (and Element class), and did not re-appear
         on the Node class..

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Dodo\Attr::__construct ( Document $nodeDocument,
?Element $ownerElement,
string $localName,
?string $prefix = null,
?string $namespaceURI = null,
string $value = "" )
Parameters
Document$nodeDocument
?Element$ownerElement
string$localName
?string$prefix
?string$namespaceURI
string$value

Member Function Documentation

◆ _empty()

bool Wikimedia\Dodo\Attr::_empty ( )

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

Reimplemented from Wikimedia\Dodo\Node.

◆ _getMissingProp()

mixed Wikimedia\Dodo\Attr::_getMissingProp ( string $name)
protected

HACK! For compatibilty with W3C test suite, which assumes that an access to 'attributes' will return null.

Parameters
string$name
Returns
mixed

Reimplemented from Wikimedia\Dodo\Node.

◆ _handleAttributeChanges()

Wikimedia\Dodo\Attr::_handleAttributeChanges ( ?Element $elem,
?string $oldValue,
?string $newValue,
bool $rootChange = false )
See also
https://dom.spec.whatwg.org/#handle-attribute-changes
Parameters
?Element$elem
?string$oldValuenull indicates this is a new element
?string$newValuenull indicates the attribute was removed
bool$rootChangeis this an update solely in rooted status?

◆ _length()

int Wikimedia\Dodo\Attr::_length ( )

See also
https://dom.spec.whatwg.org/#concept-node-length
Returns
int The length of this node.

Reimplemented from Wikimedia\Dodo\Node.

◆ _subclassCloneNodeShallow()

Attr Wikimedia\Dodo\Attr::_subclassCloneNodeShallow ( )
protected

Delegated from Node.

Returns
Attr

Reimplemented from Wikimedia\Dodo\Node.

◆ _xmlSerialize()

Wikimedia\Dodo\Attr::_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.

◆ getLocalName()

string Wikimedia\Dodo\Attr::getLocalName ( )

◆ getName()

string Wikimedia\Dodo\Attr::getName ( )

◆ getNamespaceURI()

string Wikimedia\Dodo\Attr::getNamespaceURI ( )

◆ getNodeName()

string Wikimedia\Dodo\Attr::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\Attr::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.

◆ getNodeValue()

string Wikimedia\Dodo\Attr::getNodeValue ( )
final

Return the value for this node.

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

Reimplemented from Wikimedia\Dodo\Node.

◆ getOwnerElement()

Element Wikimedia\Dodo\Attr::getOwnerElement ( )

◆ getPrefix()

string Wikimedia\Dodo\Attr::getPrefix ( )

◆ getSpecified()

bool Wikimedia\Dodo\Attr::getSpecified ( )

◆ getTextContent()

string Wikimedia\Dodo\Attr::getTextContent ( )

Return the textContent for this node.

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

Reimplemented from Wikimedia\Dodo\Node.

◆ getValue()

string Wikimedia\Dodo\Attr::getValue ( )

◆ setNodeValue()

Wikimedia\Dodo\Attr::setNodeValue ( ?string $value)
final

Reimplemented from Wikimedia\Dodo\Node.

◆ setTextContent()

Wikimedia\Dodo\Attr::setTextContent ( ?string $val)

Reimplemented from Wikimedia\Dodo\Node.

◆ setValue()

Wikimedia\Dodo\Attr::setValue ( string $value = null)

Member Data Documentation

◆ $_value

string Wikimedia\Dodo\Attr::$_value = ''
protected

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