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

The Document class. More...

+ Inheritance diagram for Wikimedia\Dodo\Document:

Public Member Functions

 __construct (string $version="1.0", string $encoding="")
 These constructor arguments are not given by the DOM spec, but are instead chosen to match the PHP constructor arguments for compatibility with the DOM extension.
 
 _setOrigin (?Document $originDoc)
 
 _setContentType (string $contentType, bool $isHtml)
 
 _setURL (?string $url)
 
Document _getTemplateDoc ()
 The children of a <template> element aren't part of the element's node document; instead they are children of an "associated inert template document". This creates that "inert template document".
 
 _setQuirksMode (string $mode)
 Used by a callback in the HTML Parser (RemexHtml) to force quirks mode depending on the value of the DOCTYPE token.
 
int getNodeType ()
 
string getNodeName ()
 
string getCharacterSet ()
 DOMTokenList. \IDLeDOM\Document::getCharacterSet()
 
string getCharset ()
 
string getInputEncoding ()
 
string getEncoding ()
 
 setEncoding (string $encoding)
 
DOMImplementation getImplementation ()
 
string getDocumentURI ()
 
string getURL ()
 
string getCompatMode ()
 
string getContentType ()
 
DocumentType getDoctype ()
 
Element getDocumentElement ()
 
Document getOwnerDocument ()
 The ownerDocument getter steps are to return null, if this is a document; otherwise this’s node document.We will override this implementation to return null in the Document class.
 
string getTitle ()
 
 setTitle (string $val)
 
string getTextContent ()
 Generic implementation of getTextContent to be used by Element and DocumentFragment (but not Document!).
See also
https://dom.spec.whatwg.org/#dom-node-textcontent
Returns
?string

 
 setTextContent (?string $value)
 Generic implementation of setTextContent to be used by Element and DocumentFragment (but not Document!).
See also
https://dom.spec.whatwg.org/#dom-node-textcontent
Parameters
?string$value

 
Text createTextNode (string $data)
 
CDATASection createCDATASection (string $data)
 
Comment createComment (string $data)
 
 createDocumentFragment ()
 
 createProcessingInstruction (string $target, string $data)
 
 createAttribute (string $localName)
 
 createAttributeNS (?string $ns, string $qname)
 
 createElement (string $lname, $options=null)
 
 createElementNS (?string $ns, string $qname, $options=null)
 
Element _createElementNS (string $lname, ?string $ns, ?string $prefix)
 This function is used directly by HTML parser, which allows it to create elements with localNames containing ':' and non-default namespaces.
 
Range createRange ()
 
NodeIterator createNodeIterator ( $root, int $whatToShow=NodeFilter::SHOW_ALL, $filter=null)
 
 _attachNodeIterator (NodeIterator $ni)
 Add a node iterator to the list of NodeIterators associated with this Document.
 
 _detachNodeIterator (NodeIterator $ni)
 Remove a node iterator from the list of NodeIterators associated with this Document.
 
 _preremoveNodeIterators (Node $toBeRemoved)
 Run preremove steps on all NodeIterators associated with this document.
 
 adoptNode ( $node)
 Adopt the subtree rooted at Node into this Document.
 
Node importNode ( $node, bool $deep=false)
 Clone and then adopt either $node or, if $deep === true, the entire subtree rooted at $node, into the Document.
 
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 _unsafeAppendChild (Node $node)
 Does not check for insertion validity.This out-performs PHP DOMDocument by over 2x.
Parameters
Node$node
Returns
Node

 
Node replaceChild ( $node, $child)
 
Node removeChild ( $child)
 
Document cloneNode (bool $deep=false)
 Clone this Document, import nodes, and call __update_document_state.
 
 getElementById (string $id)
 Fetch an Element in this Document with a given ID value.
 
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.
 
FakeElement _fakeElement ()
 A number of methods of Document act as if the Document were an Element.
 
HTMLCollection getElementsByTagName (string $lname)
 
HTMLCollection getElementsByTagNameNS (?string $ns, string $lname)
 
HTMLCollection getElementsByClassName (string $names)
 
string getInnerHTML ()
 
string getOuterHTML ()
 
bool _isHTMLDocument ()
 Return true if this document is an HTML document, otherwise it is an XML document and will return false.
 
 _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 bool saveXML ( $node=null, int $options=0)
 Creates an XML document from the DOM representation.
 
bool loadXML (string $source, int $options=0)
 Loads an XML document from a string.
 
bool loadHTML (string $source, int $options=0)
 
string bool saveHTML ( $node=null)
 Dumps the internal document into a string using HTML formatting.
 
HTMLElement null getBody ()
 
HTMLHeadElement null getHead ()
 
 _mutateValue (Node $node)
 Implementation-specific function.
 
 _mutateAttr (Attr $attr, ?string $oldval)
 Invoked when an attribute's value changes.
 
 _mutateRemoveAttr (Attr $attr)
 Used by removeAttribute and removeAttributeNS for attributes.
 
 _mutateRemove (Node $node)
 Called by Node.removeChild, etc.
 
 _mutateInsert (Node $node)
 Called when a new element becomes rooted.
 
 _mutateMove (Node $node)
 Called when a rooted element is moved within the document.
 
 _addToIdTable (string $id, Element $elt)
 
 _removeFromIdTable (string $id, Element $elt)
 
- 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.
 
- Public Member Functions inherited from Wikimedia\Dodo\Node
string getNodeValue ()
 Return the value for this node.
 
 setNodeValue (?string $val)
 
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)
 
 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.
 
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::Document
Event createEvent (string $interface)
 
TreeWalker createTreeWalker ( $root, int $whatToShow=-1, $filter=null)
 
Location null getLocation ()
 
 setLocation (string $val)
 
string getReferrer ()
 
string getCookie ()
 
 setCookie (string $val)
 
string getLastModified ()
 
string getDir ()
 
 setDir (string $val)
 
 setBody ( $val)
 
HTMLCollection getImages ()
 
HTMLCollection getEmbeds ()
 
HTMLCollection getPlugins ()
 
HTMLCollection getLinks ()
 
HTMLCollection getForms ()
 
HTMLCollection getScripts ()
 
NodeList getElementsByName (string $elementName)
 
HTMLScriptElement null getCurrentScript ()
 
Wikimedia IDLeDOM Document open (string $type='text/html', string $replace='')
 
void close ()
 
void write (string ... $text)
 
void writeln (string ... $text)
 
bool hasFocus ()
 
EventHandlerNonNull callable null getOnreadystatechange ()
 
 setOnreadystatechange ( $val)
 
HTMLCollection getAnchors ()
 
HTMLCollection getApplets ()
 
void clear ()
 
void captureEvents ()
 
void releaseEvents ()
 
bool getHidden ()
 
string getVisibilityState ()
 
EventHandlerNonNull callable null getOnvisibilitychange ()
 
 setOnvisibilitychange ( $val)
 
bool getPreserveWhiteSpace ()
 
 setPreserveWhiteSpace (bool $val)
 
bool getFormatOutput ()
 
 setFormatOutput (bool $val)
 
bool getValidateOnParse ()
 
 setValidateOnParse (bool $val)
 
bool getStrictErrorChecking ()
 
 setStrictErrorChecking (bool $val)
 
- Public Member Functions inherited from Wikimedia::IDLeDOM::DocumentOrShadowRoot
StyleSheetList getStyleSheets ()
 
- Public Member Functions inherited from Wikimedia::IDLeDOM::GlobalEventHandlers
EventHandlerNonNull callable null getOnload ()
 
 setOnload ( $val)
 
- 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::XPathEvaluatorBase
XPathExpression createExpression (string $expression, $resolver=null)
 
XPathNSResolver callable createNSResolver ( $nodeResolver)
 
XPathResult evaluate (string $expression, $contextNode, $resolver=null, int $type=0, $result=null)
 

Public Attributes

int $_modclock = 0
 This property holds a monotonically increasing value akin to a timestamp used to record the last modification time of nodes and their subtrees.
 
DocumentType $_doctype = null
 Reference to the first DocumentType child, in document order.
 
Element $_documentElement = null
 Reference to the first Element child, in document order.
 
DOMImplementation $_implementation
 The DOMImplementation associated with this Document.
 
string $_readyState
 
- 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.
 

Protected Member Functions

mixed _getMissingProp (string $name)
 
Document _subclassCloneNodeShallow ()
 Delegated method called by Node::cloneNode() Performs the shallow clone branch.
 
bool _subclassIsEqualNode (Node $other=null)
 Delegated method called by Node::isEqualNode()
 
- Protected Member Functions inherited from Wikimedia\Dodo\Node
 _setMissingProp (string $name, $value)
 

Protected Attributes

 $_contentType = 'application/xml'
 

Detailed Description

The Document class.

The HTML specification extends this class with a number of additional methods for Documents which contain HTML. We use "document type" to distinguish between XML documents and HTML documents.

Each document has an associated encoding (an encoding), content type (a string), URL (a URL), origin (an origin), type ("xml" or "html"), and mode ("no-quirks", "quirks", or "limited-quirks").

Unless stated otherwise, a document’s encoding is the utf-8 encoding, content type is "application/xml", URL is "about:blank", origin is an opaque origin, type is "xml", and its mode is "no-quirks".

A document is said to be an XML document if its type is "xml", and an HTML document otherwise. Whether a document is an HTML document or an XML document affects the behavior of certain APIs.

A document is said to be in no-quirks mode if its mode is "no-quirks", quirks mode if its mode is "quirks", and limited-quirks mode if its mode is "limited-quirks".

See also
https://html.spec.whatwg.org/multipage/dom.html#document

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Dodo\Document::__construct ( string $version = "1.0",
string $encoding = "" )

These constructor arguments are not given by the DOM spec, but are instead chosen to match the PHP constructor arguments for compatibility with the DOM extension.

See also
https://www.php.net/manual/en/domdocument.construct.php
Parameters
string$versionThe version number of the document as part of the XML declaration.
string$encodingThe encoding of the document as part of the XML declaration.

Member Function Documentation

◆ _addToIdTable()

Wikimedia\Dodo\Document::_addToIdTable ( string $id,
Element $elt )
Parameters
string$id
Element$elt

◆ _attachNodeIterator()

Wikimedia\Dodo\Document::_attachNodeIterator ( NodeIterator $ni)

Add a node iterator to the list of NodeIterators associated with this Document.

Parameters
NodeIterator$ni

◆ _createElementNS()

Element Wikimedia\Dodo\Document::_createElementNS ( string $lname,
?string $ns,
?string $prefix )

This function is used directly by HTML parser, which allows it to create elements with localNames containing ':' and non-default namespaces.

Parameters
string$lname
?string$ns
?string$prefix
Returns
Element

◆ _detachNodeIterator()

Wikimedia\Dodo\Document::_detachNodeIterator ( NodeIterator $ni)

Remove a node iterator from the list of NodeIterators associated with this Document.

Parameters
NodeIterator$ni

◆ _fakeElement()

FakeElement Wikimedia\Dodo\Document::_fakeElement ( )

A number of methods of Document act as if the Document were an Element.

Return a fake element class to make these work.

Returns
FakeElement

◆ _getElementsById()

array< Element > Wikimedia\Dodo\Document::_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>

◆ _getMissingProp()

mixed Wikimedia\Dodo\Document::_getMissingProp ( string $name)
protected
Parameters
string$name
Returns
mixed

Reimplemented from Wikimedia\Dodo\Node.

◆ _getTemplateDoc()

Document Wikimedia\Dodo\Document::_getTemplateDoc ( )

The children of a <template> element aren't part of the element's node document; instead they are children of an "associated inert template document". This creates that "inert template document".

Returns
Document

◆ _isHTMLDocument()

bool Wikimedia\Dodo\Document::_isHTMLDocument ( )

Return true if this document is an HTML document, otherwise it is an XML document and will return false.

See also
https://dom.spec.whatwg.org/#html-document
Returns
bool

◆ _mutateAttr()

Wikimedia\Dodo\Document::_mutateAttr ( Attr $attr,
?string $oldval )

Invoked when an attribute's value changes.

Attr holds the new value. oldval is the old value. Attribute mutations can also involve changes to the prefix (and therefore the qualified name)

Parameters
Attr$attr
?string$oldval

◆ _mutateInsert()

Wikimedia\Dodo\Document::_mutateInsert ( Node $node)

Called when a new element becomes rooted.

It must recursively generate mutation events for each of the children, and mark them all as rooted.

Called in Node::_insertOrReplace.

Parameters
Node$node

◆ _mutateMove()

Wikimedia\Dodo\Document::_mutateMove ( Node $node)

Called when a rooted element is moved within the document.

Parameters
Node$node

◆ _mutateRemove()

Wikimedia\Dodo\Document::_mutateRemove ( Node $node)

Called by Node.removeChild, etc.

to remove a rooted element from the tree. Only needs to generate a single mutation event when a node is removed, but must recursively mark all descendants as not rooted.

Parameters
Node$node

◆ _mutateRemoveAttr()

Wikimedia\Dodo\Document::_mutateRemoveAttr ( Attr $attr)

Used by removeAttribute and removeAttributeNS for attributes.

Parameters
Attr$attr

◆ _mutateValue()

Wikimedia\Dodo\Document::_mutateValue ( Node $node)

Implementation-specific function.

Called when a text, comment, or pi value changes.

Parameters
Node$node

◆ _preremoveNodeIterators()

Wikimedia\Dodo\Document::_preremoveNodeIterators ( Node $toBeRemoved)

Run preremove steps on all NodeIterators associated with this document.

Parameters
Node$toBeRemovedthe Node about to be removed

◆ _removeFromIdTable()

Wikimedia\Dodo\Document::_removeFromIdTable ( string $id,
Element $elt )
Parameters
string$id
Element$elt

◆ _setContentType()

Wikimedia\Dodo\Document::_setContentType ( string $contentType,
bool $isHtml )
Parameters
string$contentType
bool$isHtmlWhether this is to be an "HTML document"

◆ _setOrigin()

Wikimedia\Dodo\Document::_setOrigin ( ?Document $originDoc)
Parameters
?Document$originDoc

◆ _setQuirksMode()

Wikimedia\Dodo\Document::_setQuirksMode ( string $mode)

Used by a callback in the HTML Parser (RemexHtml) to force quirks mode depending on the value of the DOCTYPE token.

See also
https://html.spec.whatwg.org/multipage/parsing.html#the-initial-insertion-mode
Parameters
string$mode

◆ _setURL()

Wikimedia\Dodo\Document::_setURL ( ?string $url)
Parameters
?string$url

◆ _subclassCloneNodeShallow()

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

Delegated method called by Node::cloneNode() Performs the shallow clone branch.

spec Dodo

Returns
Document with same invocation as $this

Reimplemented from Wikimedia\Dodo\Node.

◆ _subclassIsEqualNode()

bool Wikimedia\Dodo\Document::_subclassIsEqualNode ( Node $other = null)
protected

Delegated method called by Node::isEqualNode()

spec DOM-LS

NOTE: Any two Documents are shallowly equal, since equality is determined by their children; this will be tested by Node::isEqualNode(), so just return true.

Parameters
Node | null$otherto compare
Returns
bool True (two Documents are always equal)

Reimplemented from Wikimedia\Dodo\Node.

◆ _unsafeAppendChild()

Node Wikimedia\Dodo\Document::_unsafeAppendChild ( Node $node)

Does not check for insertion validity.This out-performs PHP DOMDocument by over 2x.

Parameters
Node$node
Returns
Node

Reimplemented from Wikimedia\Dodo\Node.

◆ _xmlSerialize()

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

◆ adoptNode()

Wikimedia\Dodo\Document::adoptNode ( $node)

Adopt the subtree rooted at Node into this Document.

This means setting ownerDocument of each node in the subtree to point to $this.

No insertion is performed, but if Node is inserted into another Document, it will be removed.

Implements Wikimedia::IDLeDOM::Document.

◆ cloneNode()

Document Wikimedia\Dodo\Document::cloneNode ( bool $deep = false)

Clone this Document, import nodes, and call __update_document_state.

extends Node::cloneNode() spec DOM-LS

NOTE:

  1. With Document nodes, we need to take the additional step of calling importNode() to bring copies of child nodes into this document.
  2. We also need to call _updateDocTypeElement()
Parameters
bool$deepif true, clone entire document
Returns
Document

Reimplemented from Wikimedia\Dodo\Node.

◆ createAttribute()

Wikimedia\Dodo\Document::createAttribute ( string $localName)

◆ createAttributeNS()

Wikimedia\Dodo\Document::createAttributeNS ( ?string $ns,
string $qname )

◆ createCDATASection()

CDATASection Wikimedia\Dodo\Document::createCDATASection ( string $data)

◆ createComment()

Comment Wikimedia\Dodo\Document::createComment ( string $data)

◆ createDocumentFragment()

Wikimedia\Dodo\Document::createDocumentFragment ( )

◆ createElement()

Wikimedia\Dodo\Document::createElement ( string $lname,
$options = null )

◆ createElementNS()

Wikimedia\Dodo\Document::createElementNS ( ?string $ns,
string $qname,
$options = null )

◆ createNodeIterator()

NodeIterator Wikimedia\Dodo\Document::createNodeIterator ( $root,
int $whatToShow = NodeFilter::SHOW_ALL,
$filter = null )
See also
http://www.w3.org/TR/dom/#dom-document-createnodeiterator
Parameters
\Wikimedia\IDLeDOM\Node$root
int$whatToShow
\Wikimedia\IDLeDOM\NodeFilter | callable | null$filter
Returns
NodeIterator

Implements Wikimedia::IDLeDOM::Document.

◆ createProcessingInstruction()

Wikimedia\Dodo\Document::createProcessingInstruction ( string $target,
string $data )

◆ createRange()

Range Wikimedia\Dodo\Document::createRange ( )

◆ createTextNode()

Text Wikimedia\Dodo\Document::createTextNode ( string $data)

◆ getBody()

HTMLElement null Wikimedia\Dodo\Document::getBody ( )
Returns
HTMLElement|null

Implements Wikimedia::IDLeDOM::Document.

◆ getCharacterSet()

string Wikimedia\Dodo\Document::getCharacterSet ( )

DOMTokenList. \IDLeDOM\Document::getCharacterSet()

Note that duplicates are permitted!

See also
https://dom.spec.whatwg.org/#domtokenlist \Dodo -forbid-undeclared-magic-properties \IDLeDOM\Document::getCharacterSet()

Implements Wikimedia::IDLeDOM::Document.

◆ getCharset()

string Wikimedia\Dodo\Document::getCharset ( )
Returns
string

Implements Wikimedia::IDLeDOM::Document.

◆ getCompatMode()

string Wikimedia\Dodo\Document::getCompatMode ( )

◆ getContentType()

string Wikimedia\Dodo\Document::getContentType ( )

◆ getDoctype()

DocumentType Wikimedia\Dodo\Document::getDoctype ( )

◆ getDocumentElement()

Element Wikimedia\Dodo\Document::getDocumentElement ( )

◆ getDocumentURI()

string Wikimedia\Dodo\Document::getDocumentURI ( )

◆ getElementById()

Wikimedia\Dodo\Document::getElementById ( string $id)

Fetch an Element in this Document with a given ID value.

spec DOM-LS

NOTE In the spec, this is actually the sole method of the NonElementParentNode mixin.

Implements Wikimedia::IDLeDOM::NonElementParentNode.

◆ getElementsByClassName()

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

Implements Wikimedia::IDLeDOM::Document.

◆ getElementsByTagName()

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

Implements Wikimedia::IDLeDOM::Document.

◆ getElementsByTagNameNS()

HTMLCollection Wikimedia\Dodo\Document::getElementsByTagNameNS ( ?string $ns,
string $lname )
Parameters
string | null$ns
string$lname
Returns
HTMLCollection

Implements Wikimedia::IDLeDOM::Document.

◆ getEncoding()

string Wikimedia\Dodo\Document::getEncoding ( )
Returns
string

Implements Wikimedia::IDLeDOM::Document.

◆ getHead()

HTMLHeadElement null Wikimedia\Dodo\Document::getHead ( )
Returns
HTMLHeadElement|null

Implements Wikimedia::IDLeDOM::Document.

◆ getImplementation()

DOMImplementation Wikimedia\Dodo\Document::getImplementation ( )
Returns
DOMImplementation

Implements Wikimedia::IDLeDOM::Document.

◆ getInnerHTML()

string Wikimedia\Dodo\Document::getInnerHTML ( )
Returns
string the inner HTML of this Document

◆ getInputEncoding()

string Wikimedia\Dodo\Document::getInputEncoding ( )
Returns
string

Implements Wikimedia::IDLeDOM::Document.

◆ getNodeName()

string Wikimedia\Dodo\Document::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\Document::getNodeType ( )

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\Document::getOuterHTML ( )
Returns
string the outer HTML of this Document

◆ getOwnerDocument()

Document Wikimedia\Dodo\Document::getOwnerDocument ( )

The ownerDocument getter steps are to return null, if this is a document; otherwise this’s node document.We will override this implementation to return null in the Document class.

Reimplemented from Wikimedia\Dodo\Node.

◆ getTextContent()

string Wikimedia\Dodo\Document::getTextContent ( )

Generic implementation of getTextContent to be used by Element and DocumentFragment (but not Document!).

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

Reimplemented from Wikimedia\Dodo\ContainerNode.

◆ getTitle()

string Wikimedia\Dodo\Document::getTitle ( )

◆ getURL()

string Wikimedia\Dodo\Document::getURL ( )
Returns
string

Alias for HTMLDocuments

Implements Wikimedia::IDLeDOM::Document.

◆ importNode()

Node Wikimedia\Dodo\Document::importNode ( $node,
bool $deep = false )

Clone and then adopt either $node or, if $deep === true, the entire subtree rooted at $node, into the Document.

By default, only $node will be cloned.

Implements Wikimedia::IDLeDOM::Document.

◆ insertBefore()

Node Wikimedia\Dodo\Document::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"

Reimplemented from Wikimedia\Dodo\Node.

◆ loadHTML()

bool Wikimedia\Dodo\Document::loadHTML ( string $source,
int $options = 0 )
See also
https://www.php.net/manual/en/domdocument.loadhtml.php
Parameters
string$sourceThe HTML string
int$optionsAdditional libxml parameters
Returns
bool Returns true on success or false on failure

Implements Wikimedia::IDLeDOM::Document.

◆ loadXML()

bool Wikimedia\Dodo\Document::loadXML ( string $source,
int $options = 0 )

Loads an XML document from a string.

Non-standard: PHP extension.

See also
https://www.php.net/manual/en/domdocument.loadxml.php
Parameters
string$sourceThe string containing the XML.
int$optionsBitwise OR of the libxml option constants.
Returns
bool Returns true on success or false on failure.

Implements Wikimedia::IDLeDOM::Document.

◆ removeChild()

Node Wikimedia\Dodo\Document::removeChild ( $child)

Reimplemented from Wikimedia\Dodo\Node.

◆ replaceChild()

Node Wikimedia\Dodo\Document::replaceChild ( $node,
$child )

Reimplemented from Wikimedia\Dodo\Node.

◆ saveHTML()

string bool Wikimedia\Dodo\Document::saveHTML ( $node = null)

Dumps the internal document into a string using HTML formatting.

See also
https://www.php.net/manual/en/domdocument.savehtml.php
Parameters
Node | null$nodeOptional parameter to output a subset of the document
Returns
string|bool Returns the HTML string, or false if an error occurred

Implements Wikimedia::IDLeDOM::Document.

◆ saveXML()

string bool Wikimedia\Dodo\Document::saveXML ( $node = null,
int $options = 0 )

Creates an XML document from the DOM representation.

Non-standard: PHP extension.

See also
https://www.php.net/manual/en/domdocument.savexml.php
Parameters
Node | null$nodeOutput only a specific node rather than the entire document.
int$optionsAdditional options. Only LIBXML_NOEMPTYTAG is supported.
Returns
string|bool Returns the XML, or false if an error occurred.

Implements Wikimedia::IDLeDOM::Document.

◆ setEncoding()

Wikimedia\Dodo\Document::setEncoding ( string $encoding)
Parameters
string$encoding

Implements Wikimedia::IDLeDOM::Document.

◆ setTextContent()

Wikimedia\Dodo\Document::setTextContent ( ?string $value)

Generic implementation of setTextContent to be used by Element and DocumentFragment (but not Document!).

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

Reimplemented from Wikimedia\Dodo\ContainerNode.

◆ setTitle()

Wikimedia\Dodo\Document::setTitle ( string $val)

Member Data Documentation

◆ $_doctype

DocumentType Wikimedia\Dodo\Document::$_doctype = null

Reference to the first DocumentType child, in document order.

Null if no such child exists.

◆ $_documentElement

Element Wikimedia\Dodo\Document::$_documentElement = null

Reference to the first Element child, in document order.

Null if no such child exists.

◆ $_modclock

int Wikimedia\Dodo\Document::$_modclock = 0

This property holds a monotonically increasing value akin to a timestamp used to record the last modification time of nodes and their subtrees.

See the lastModTime attribute and modify() method of the Node class. And see FilteredElementList for an example of the use of lastModTime.


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