DOM

DOM

Source

To a node, with an optional suppress observers flag, run these steps:

  1. Let parent be node’s parent

  2. Assert: parent is non-null.

  3. Let index be node’s index.

  4. For each live range whose start node is an inclusive descendant of node, set its start to (parent, index).

  5. For each live range whose end node is an inclusive descendant of node, set its end to (parent, index).

  6. For each live range whose start node is parent and start offset is greater than index, decrease its start offset by 1.

  7. For each live range whose end node is parent and end offset is greater than index, decrease its end offset by 1.

  8. For each NodeIterator object iterator whose root’s node document is node’s node document, run the NodeIterator pre-removing steps given node and iterator.

  9. Let oldPreviousSibling be node’s previous sibling.

  10. Let oldNextSibling be node’s next sibling.

  11. Remove node from its parent’s children.

  12. If node is assigned, then run assign slottables for node’s assigned slot.

  13. 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.

  14. If node has an inclusive descendant that is a slot, then:

  15. Run the removing steps with node and parent.

  16. Let isParentConnected be parent’s connected.

  17. 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.

  18. For each shadow-including descendant descendant of node, in shadow-including tree order, then:

  19. 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.

  20. If suppress observers flag is unset, then queue a tree mutation record for parent with « », « node », oldPreviousSibling, and oldNextSibling.

  21. 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.

Document/getElementById

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.

Document/children

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+

DocumentFragment/children

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+

Element/children

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.

Document/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+

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+

Element/firstElementChild

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.

Document/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+

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+

Element/lastElementChild

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

Report Page