Path: blob/main/website/awaited-dom/DocumentFragment.md
2707 views
AwaitedDOM / DocumentFragment
DocumentFragment interface represents a minimal document object that has no parent. It is used as a lightweight version of Document that stores a segment of a document structure comprised of nodes just like a standard document. The key difference is due to the fact that the document fragment isn't part of the active document tree structure. Changes made to the fragment don't affect the document (even on reflow) or incur any performance impact when changes are made.Properties
doc.baseURI W3C {#baseURI}
Returns a string representing the base URL of the document containing the Node.
Type: Promise<string>
doc.childNodes W3C {#childNodes}
Returns a live NodeList containing all the children of this node. NodeList being live means that if the children of the Node change, the NodeList object is automatically updated.
Type: SuperNodeList
doc.firstChild W3C {#firstChild}
Returns a Node representing the first direct child node of the node, or null if the node has no child.
Type: SuperNode
doc.isConnected W3C {#isConnected}
A boolean indicating whether or not the Node is connected (directly or indirectly) to the context object, e.g. the Document object in the case of the normal DOM, or the ShadowRoot in the case of a shadow DOM.
Type: Promise<boolean>
doc.lastChild W3C {#lastChild}
Returns a Node representing the last direct child node of the node, or null if the node has no child.
Type: SuperNode
doc.nextSibling W3C {#nextSibling}
Returns a Node representing the next node in the tree, or null if there isn't such node.
Type: SuperNode
doc.nodeName W3C {#nodeName}
Returns a string containing the name of the Node. The structure of the name will differ with the node type. E.g. An HTMLElement will contain the name of the corresponding tag, like 'audio' for an HTMLAudioElement, a Text node will have the '#text' string, or a Document node will have the '#document' string.
Type: Promise<string>
doc.nodeType W3C {#nodeType}
Returns an unsigned short representing the type of the node. Possible values are:
Name Value ELEMENT_NODE1ATTRIBUTE_NODE 2TEXT_NODE3CDATA_SECTION_NODE4ENTITY_REFERENCE_NODE 5ENTITY_NODE 6PROCESSING_INSTRUCTION_NODE7COMMENT_NODE8DOCUMENT_NODE9DOCUMENT_TYPE_NODE10DOCUMENT_FRAGMENT_NODE11NOTATION_NODE 12
Type: Promise<number>
doc.nodeValue W3C {#nodeValue}
Returns / Sets the value of the current node.
Type: Promise<string>
doc.ownerDocument W3C {#ownerDocument}
Returns the Document that this node belongs to. If the node is itself a document, returns null.
Type: SuperDocument
doc.parentElement W3C {#parentElement}
Returns an Element that is the parent of this node. If the node has no parent, or if that parent is not an Element, this property returns null.
Type: SuperElement
doc.parentNode W3C {#parentNode}
Returns a Node that is the parent of this node. If there is no such node, like if this node is the top of the tree or if doesn't participate in a tree, this property returns null.
Type: SuperNode
doc.previousSibling W3C {#previousSibling}
Returns a Node representing the previous node in the tree, or null if there isn't such node.
Type: SuperNode
doc.textContent W3C {#textContent}
Returns / Sets the textual content of an element and all its descendants.
Type: Promise<string>
doc.childElementCount W3C {#childElementCount}
Returns the number of children of this ParentNode which are elements.
Type: Promise<number>
doc.children W3C {#children}
Returns a live HTMLCollection containing all of the Element objects that are children of this ParentNode, omitting all of its non-element nodes.
Type: SuperHTMLCollection
doc.firstElementChild W3C {#firstElementChild}
Returns the first node which is both a child of this ParentNode and is also an Element, or null if there is none.
Type: SuperElement
doc.lastElementChild W3C {#lastElementChild}
Returns the last node which is both a child of this ParentNode and is an Element, or null if there is none.
Type: SuperElement
Methods
doc.compareDocumentPosition*(other)* W3C {#compareDocumentPosition}
Compares the position of the current node against another node in any other document.
Arguments:
other
Node. The otherNodewith which to compare the firstnode’s document position.
Returns: Promise<number>
doc.contains*(other)* W3C {#contains}
Returns a boolean value indicating whether or not a node is a descendant of the calling node.
Arguments:
other
Node. Needs content.
Returns: Promise<boolean>
doc.getRootNode*(options?)* W3C {#getRootNode}
Returns the context object's root which optionally includes the shadow root if it is available.
Arguments:
options
GetRootNodeOptions. An object that sets options for getting the root node. The available options are:composed: A `boolean` that indicates whether the shadow root should be returned (false, the default), or a root node beyond shadow root (true).
Returns: SuperNode
doc.hasChildNodes*()* W3C {#hasChildNodes}
Returns a boolean indicating whether or not the element has any child nodes.
Returns: Promise<boolean>
doc.isDefaultNamespace*(namespace)* W3C {#isDefaultNamespace}
Accepts a namespace URI as an argument and returns a boolean with a value of true if the namespace is the default namespace on the given node or false if not.
Arguments:
namespace
string.namespaceURIis a string representing the namespace against which the element will be checked.
Returns: Promise<boolean>
doc.isEqualNode*(otherNode)* W3C {#isEqualNode}
Returns a boolean which indicates whether or not two nodes are of the same type and all their defining data points match.
Arguments:
otherNode
Node.otherNode: TheNodeto compare equality with.
Returns: Promise<boolean>
doc.isSameNode*(otherNode)* W3C {#isSameNode}
Returns a boolean value indicating whether or not the two nodes are the same (that is, they reference the same object).
Arguments:
otherNode
Node.otherNodeTheNodeto test against.
Returns: Promise<boolean>
doc.lookupNamespaceURI*(prefix)* W3C {#lookupNamespaceURI}
Accepts a prefix and returns the namespace URI associated with it on the given node if found (and null if not). Supplying null for the prefix will return the default namespace.
Arguments:
prefix
string. The prefix to look for. If this parameter isnull, the method will return the default namespace URI, if any.
Returns: Promise<string>
doc.lookupPrefix*(namespace)* W3C {#lookupPrefix}
Returns a string containing the prefix for a given namespace URI, if present, and null if not. When multiple prefixes are possible, the result is implementation-dependent.
Arguments:
namespace
string. Needs content.
Returns: Promise<string>
doc.normalize*()* W3C {#normalize}
Clean up all the text nodes under this element (merge adjacent, remove empty).
Returns: Promise<void>
doc.getElementById*(elementId)* W3C {#getElementById}
Needs content.
Arguments:
elementId
string. Needs content.
Returns: SuperElement
doc.querySelector*(selectors)* W3C {#querySelector}
Returns the first Element with the current element as root that matches the specified group of selectors.
Arguments:
selectors
string. Astringcontaining one or more selectors to match against. This string must be a valid compound selector list supported by the browser; if it's not, aSyntaxErrorexception is thrown. See Locating DOM elements using selectors for more information about using selectors to identify elements. Multiple selectors may be specified by separating them using commas.
Returns: SuperElement
doc.querySelectorAll*(selectors)* W3C {#querySelectorAll}
Returns a NodeList representing a list of elements with the current element as root that matches the specified group of selectors.
Arguments:
selectors
string. Astringcontaining one or more selectors to match against. This string must be a valid CSS selector string; if it's not, aSyntaxErrorexception is thrown. See Locating DOM elements using selectors for more information about using selectors to identify elements. Multiple selectors may be specified by separating them using commas.
Returns: SuperNodeList
Unimplemented Specs
Methods
appendChild() | cloneNode() |
insertBefore() | removeChild() |
replaceChild() | addEventListener() |
dispatchEvent() | removeEventListener() |
append() | prepend() |