DOM

DOM

Source

The textContent getter steps are to return the
following, switching on this:

DocumentFragment Element The descendant text content of this. Attr this’s value. Text ProcessingInstruction Comment this’s data. Any other node Null.

To string replace all with a string string within a node parent, run these steps:

The textContent setter steps are to, if the given value is null, act as if it was the
empty string instead, and then do as described below, switching on this:

DocumentFragment Element

String replace all with the given value within this.

Attr

Set an existing attribute value with this and new value.

Text ProcessingInstruction Comment

Replace data with node this, offset 0, count this’s length, and data the given value.

Any other node

Do nothing.

node . normalize() Removes empty exclusive Text nodes and concatenates the data of remaining contiguous exclusive Text nodes into the first of their nodes.

Node/normalize

In all current engines.

Firefox1+Safari1+Chrome1+ Opera12.1+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari1+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile12.1+

The normalize() method steps are to run these steps for
each descendant exclusive Text node node of this:

  1. Let length be node’s length.
  2. If length is zero, then remove node and continue with the next exclusive Text node, if any.
  3. Let data be the concatenation of the data of node’s contiguous exclusive Text nodes (excluding itself), in tree order.
  4. Replace data with node node, offset length, count 0, and data data.
  5. Let currentNode be node’s next sibling.
  6. While currentNode is an exclusive Text node:

  7. Remove node’s contiguous exclusive Text nodes (excluding itself), in tree order.
node . cloneNode([deep = false]) Returns a copy of node. If deep is true, the copy also includes the node’s descendants. node . isEqualNode(otherNode) Returns whether node and otherNode have the same properties.

Specifications may define cloning steps for all or some nodes. The
algorithm is passed copy, node, document, and an optional clone children flag, as indicated in the clone algorithm.

HTML defines cloning steps for script and input elements. SVG ought to do the same for its script elements, but does not call this out
at the moment.

To clone a node, with an optional document and clone children flag, run these
steps:

  1. If document is not given, let document be node’s node document.

  2. If node is an element, then:

  3. Otherwise, let copy be a node that implements the same interfaces as node, and fulfills these additional requirements, switching on node:

    Document

    Set copy’s encoding, content type, URL, origin, type, and mode, to those of node.

    DocumentType

    Set copy’s name, public ID, and system ID, to those of node.

    Attr

    Set copy’s namespace, namespace prefix, local name, and value, to those of node.

    Text Comment Set copy’s data, to that of node. ProcessingInstruction Set copy’s target and data to those of node. Any other node —
  4. Set copy’s node document and document to copy, if copy is a document, and set copy’s node document to document otherwise.

  5. Run any cloning steps defined for node in other applicable specifications and pass copy, node, document and the clone children flag if set, as parameters.
  6. If the clone children flag is set, clone all the children of node and append them to copy, with document as specified and the clone children flag being set.
  7. Return copy.

Node/cloneNode

In all current engines.

Firefox1+Safari1.1+Chrome1+ Opera7+Edge79+ Edge (Legacy)12+IE6+ Firefox for Android4+iOS Safari1+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile10.1+

The cloneNode(deep) method steps are:

A node A equals a node B if all of the following conditions are true:

Node/isEqualNode

In all current engines.

Firefox2+Safari3+Chrome1+ Opera12.1+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari1+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile12.1+

The isEqualNode(otherNode) method steps are to
return true if otherNode is non-null and this equals otherNode; otherwise false.

Node/isSameNode

In all current engines.

Firefox48+Safari3+Chrome1+ Opera12.1+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android48+iOS Safari1+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile12.1+

The isSameNode(otherNode) method steps are to
return true if otherNode is this; otherwise false.

node . compareDocumentPosition(other) Returns a bitmask indicating the position of other relative to node. These are the bits that can be set: Node . DOCUMENT_POSITION_DISCONNECTED (1) Set when node and other are not in the same tree. Node . DOCUMENT_POSITION_PRECEDING (2) Set when other is preceding node. Node . DOCUMENT_POSITION_FOLLOWING (4) Set when other is following node. Node . DOCUMENT_POSITION_CONTAINS (8) Set when other is an ancestor of node. Node . DOCUMENT_POSITION_CONTAINED_BY (16, 10 in hexadecimal) Set when other is a descendant of node. node . contains(other) Returns true if other is an inclusive descendant of node; otherwise false.

These are the constants compareDocumentPosition() returns as mask:

  • DOCUMENT_POSITION_DISCONNECTED (1);
  • DOCUMENT_POSITION_PRECEDING (2);
  • DOCUMENT_POSITION_FOLLOWING (4);
  • DOCUMENT_POSITION_CONTAINS (8);
  • DOCUMENT_POSITION_CONTAINED_BY (16, 10 in hexadecimal);
  • DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC (32, 20 in hexadecimal).

Node/compareDocumentPosition

In all current engines.

Firefox9+Safari4+Chrome1+ Opera12.1+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android9+iOS Safari3.2+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile12.1+

The compareDocumentPosition(other) method
steps are:

  1. If this is other, then return zero.

  2. Let node1 be other and node2 be this.

  3. Let attr1 and attr2 be null.

  4. If node1 is an attribute, then set attr1 to node1 and node1 to attr1’s element.

  5. If node2 is an attribute, then:

  6. If node1 or node2 is null, or node1’s root is not node2’s root, then return the result of adding DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, and either DOCUMENT_POSITION_PRECEDING or DOCUMENT_POSITION_FOLLOWING, with the constraint that this is to be consistent, together.

    Whether to return DOCUMENT_POSITION_PRECEDING or DOCUMENT_POSITION_FOLLOWING is typically implemented via pointer comparison. In JavaScript implementations a cached Math.random() value can be used.

  7. If node1 is an ancestor of node2 and attr1 is null, or node1 is node2 and attr2 is non-null, then return the result of adding DOCUMENT_POSITION_CONTAINS to DOCUMENT_POSITION_PRECEDING.

  8. If node1 is a descendant of node2 and attr2 is null, or node1 is node2 and attr1 is non-null, then return the result of adding DOCUMENT_POSITION_CONTAINED_BY to DOCUMENT_POSITION_FOLLOWING.

  9. If node1 is preceding node2, then return DOCUMENT_POSITION_PRECEDING.

    Due to the way attributes are handled in this algorithm this results in a node’s attributes counting as preceding that node’s children, despite attributes not participating in a tree.

  10. Return DOCUMENT_POSITION_FOLLOWING.

Node/contains

In all current engines.

Firefox9+Safari1.1+Chrome16+ Opera7+Edge79+ Edge (Legacy)12+IENone Firefox for Android9+iOS Safari1+Chrome for Android18+Android WebView37+Samsung Internet1.0+Opera Mobile10.1+

The contains(other) method steps are to return
true if other is an inclusive descendant of this; otherwise false
(including when other is null).

To locate a namespace prefix for an element using namespace, run these steps:

To locate a namespace for a node using prefix, switch on node:

Element Document DocumentType DocumentFragment

Return null.

Attr Any other node

The lookupPrefix(namespace) method steps are:

Node/lookupNamespaceURI

In all current engines.

Firefox1+Safari3+Chrome1+ Opera12.1+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari1+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile12.1+

The lookupNamespaceURI(prefix) method steps
are:

  1. If prefix is the empty string, then set it to null.

  2. Return the result of running locate a namespace for this using prefix.

Node/isDefaultNamespace

In all current engines.

Firefox1+Safari3+Chrome1+ Opera12.1+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari1+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile12.1+

The isDefaultNamespace(namespace) method steps
are:

  1. If namespace is the empty string, then set it to null.

  2. Let defaultNamespace be the result of running locate a namespace for this using null.

  3. Return true if defaultNamespace is the same as namespace; otherwise false.

Node/insertBefore

In all current engines.

Firefox3+Safari1.1+Chrome1+ Opera7+Edge79+ Edge (Legacy)12+IE6+ Firefox for Android4+iOS Safari1+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile10.1+

The insertBefore(node, child) method steps are to return the result of pre-inserting node into this before child.

Node/appendChild

In all current engines.

Firefox1+Safari1.1+Chrome1+ Opera7+Edge79+ Edge (Legacy)12+IE5+ Firefox for Android4+iOS Safari1+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile10.1+

The appendChild(node) method steps are to
return the result of appending node to this.

Node/replaceChild

In all current engines.

Firefox1+Safari1.1+Chrome1+ Opera7+Edge79+ Edge (Legacy)12+IE6+ Firefox for Android4+iOS Safari1+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile10.1+

The replaceChild(node, child) method steps are to return the result of replacing child with node within this.

Node/removeChild

In all current engines.

Firefox1+Safari1.1+Chrome1+ Opera7+Edge79+ Edge (Legacy)12+IE5+ Firefox for Android4+iOS Safari1+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile10.1+

The method steps are to
return the result of pre-removing child from this.

The list of elements with qualified name qualifiedName for a node root is the HTMLCollection returned by the following algorithm:

When invoked with the same argument, and as long as root’s node document’s type has not changed, the same HTMLCollection object may be returned as returned by an earlier call.

The list of elements with namespace namespace and local name localName for a node root is the HTMLCollection returned by the following algorithm:



Read Next page

Report Page