DOM
SourceTo a node, with an optional suppress observers flag, run these steps:
-
Let parent be node’s parent
-
Assert: parent is non-null.
-
Let index be node’s index.
-
For each live range whose start node is an inclusive descendant of node, set its start to (parent, index).
-
For each live range whose end node is an inclusive descendant of node, set its end to (parent, index).
-
For each live range whose start node is parent and start offset is greater than index, decrease its start offset by 1.
-
For each live range whose end node is parent and end offset is greater than index, decrease its end offset by 1.
-
For each
NodeIterator
object iterator whose root’s node document is node’s node document, run theNodeIterator
pre-removing steps given node and iterator. -
Let oldPreviousSibling be node’s previous sibling.
-
Let oldNextSibling be node’s next sibling.
-
If node is assigned, then run assign slottables for node’s assigned slot.
-
If parent’s root is a shadow root, and parent is a slot whose assigned nodes is the empty list, then run signal a slot change for parent.
-
If node has an inclusive descendant that is a slot, then:
-
Run the removing steps with node and parent.
-
Let isParentConnected be parent’s connected.
-
If node is custom and isParentConnected is true, then enqueue a custom element callback reaction with node, callback name "
disconnectedCallback
", and an empty argument list.It is intentional for now that custom elements do not get parent passed. This might change in the future if there is a need.
-
For each shadow-including descendant descendant of node, in shadow-including tree order, then:
-
For each inclusive ancestor inclusiveAncestor of parent, and then for each registered of inclusiveAncestor’s registered observer list, if registered’s options["
subtree
"] is true, then append a new transient registered observer whose observer is registered’s observer, options is registered’s options, and source is registered to node’s registered observer list. -
If suppress observers flag is unset, then queue a tree mutation record for parent with « », « node », oldPreviousSibling, and oldNextSibling.
-
Run the children changed steps for parent.
Web compatibility prevents the getElementById()
method from being exposed on elements (and therefore on ParentNode
).
interface mixin NonElementParentNode
{ );
};
Document includes NonElementParentNode;
DocumentFragment includes NonElementParentNode;
node . getElementById(elementId)
Returns the first element within node’s descendants whose ID is elementId.
In all current engines.
Firefox1+Safari1+Chrome1+ Opera7+Edge79+ Edge (Legacy)12+IE5.5+ Firefox for Android4+iOS Safari1+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile10.1+
The getElementById(elementId)
method steps are to return the first element, in tree order, within this’s descendants, whose ID is elementId; otherwise, if
there is no such element, null.
interface mixin DocumentOrShadowRoot
{
};
Document includes DocumentOrShadowRoot;
ShadowRoot includes DocumentOrShadowRoot;
The DocumentOrShadowRoot
mixin is expected to be used by other
standards that want to define APIs shared between ); [); [); ); [);
};
Document includes ParentNode;
DocumentFragment includes ParentNode;
Element includes ParentNode;
collection = node . children
Returns the child elements. element = node . firstElementChild
Returns the first child that is an element; otherwise null. element = node . lastElementChild
Returns the last child that is an element; otherwise null. node . prepend(nodes)
Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text
nodes.
Throws a "HierarchyRequestError
" DOMException
if the constraints of the node tree are violated.
node . append(nodes)
Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text
nodes.
Throws a "HierarchyRequestError
" DOMException
if the constraints of the node tree are violated.
node . replaceChildren(nodes)
Replace all children of node with nodes, while replacing strings in nodes with equivalent Text
nodes.
Throws a "HierarchyRequestError
" DOMException
if the constraints of the node tree are violated.
node . querySelector(selectors)
Returns the first element that is a descendant of node that matches selectors. node . querySelectorAll(selectors)
Returns all element descendants of node that match selectors. In all current engines.
Firefox25+Safari9+Chrome29+ Opera16+Edge79+ Edge (Legacy)16+IENone Firefox for Android25+iOS Safari9+Chrome for Android29+Android WebView37+Samsung Internet2.0+Opera Mobile16+
In all current engines.
Firefox25+Safari9+Chrome29+ Opera16+Edge79+ Edge (Legacy)16+IENone Firefox for Android25+iOS Safari9+Chrome for Android29+Android WebView37+Samsung Internet2.0+Opera Mobile16+
In all current engines.
Firefox3.5+Safari4+Chrome1+ Opera10+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile10.1+
The children
getter steps are to return an HTMLCollection
collection rooted at this matching only element children.
In all current engines.
Firefox25+Safari9+Chrome29+ Opera16+Edge79+ Edge (Legacy)17+IENone Firefox for Android25+iOS Safari9+Chrome for Android29+Android WebView37+Samsung Internet2.0+Opera Mobile16+
DocumentFragment/firstElementChild
In all current engines.
Firefox25+Safari9+Chrome29+ Opera16+Edge79+ Edge (Legacy)17+IENone Firefox for Android25+iOS Safari9+Chrome for Android29+Android WebView37+Samsung Internet2.0+Opera Mobile16+
In all current engines.
Firefox3.5+Safari4+Chrome1+ Opera10+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile10.1+
The firstElementChild
getter steps are to return
the first child that is an element; otherwise null.
In all current engines.
Firefox25+Safari9+Chrome29+ Opera16+Edge79+ Edge (Legacy)17+IENone Firefox for Android25+iOS Safari9+Chrome for Android29+Android WebView37+Samsung Internet2.0+Opera Mobile16+
DocumentFragment/lastElementChild
In all current engines.
Firefox25+Safari9+Chrome29+ Opera16+Edge79+ Edge (Legacy)17+IENone Firefox for Android25+iOS Safari9+Chrome for Android29+Android WebView37+Samsung Internet2.0+Opera Mobile16+
In all current engines.
Firefox3.5+Safari4+Chrome1+ Opera10+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile10.1+
Read Next page