Skip to main content

class Node

Node is an abstract class that is inherited by Element, Text and Comment classes.

properties:

nodeName

string, read-only, one of

ValueNode Type
"#comment"Comment
"#text"Text
"#document"Document
The value of element.tagNameElement

nodeType

read-only, integer, node type

nodeValue

  • Text and Comment nodes - read-write, string, text of the node;
  • other node types - read-only, null

nodeIndex

read-only, integer, index of the node in its parent collection.

childNodes

read-only, returns a NodeList containing all children.

firstChild

lastChild

read-only, returns first/last child Node.

nextSibling

previousSibling

read-only, returns next/previous sibling Node.

parentNode

parentElement

read-only, reference of parent element.

ownerDocument

read-only, owning document reference.

parentWindow

read-only instance of Window that hosts this node;

textContent

  • Text and Comment nodes - read-only, string, text of the node;
  • other node types - textual content of an element - concatenation of textContent of all its descendants

methods:

cloneNode()

const clone = node.cloneNode();
danger

In Sciter this method always does deep cloning.

contains()

node.contains(otherNode): boolean

returns true if this node contains other node as a descendant.

### compareDocumentPosition()

not implemened yet.

getRootNode()

node.getRootNode(): Document | null

read-only, in Sciter it always reports ownerDocument.

hasChildNodes()

node.hasChildNodes(): bool

reports true if it has child nodes.

isEqualNode()

node.isEqualNode(otherNode): bool

reports true if it has child nodes.

isSameNode()

node.isSameNode(otherNode): bool

reports true if node === otherNode

remove()

node.remove()

method removes the node from the DOM.

static methods:

commonParent()

Node.commonParent(nodeA,nodeB):Element

returns nearest common parent element of two nodes;

static constants:

NodeType

  • Node.ELEMENT_NODE
  • Node.ATTRIBUTE_NODE
  • Node.TEXT_NODE
  • Node.CDATA_SECTION_NODE
  • Node.PROCESSING_INSTRUCTION_NODE
  • Node.COMMENT_NODE
  • Node.DOCUMENT_NODE
  • Node.DOCUMENT_TYPE_NODE
  • Node.DOCUMENT_FRAGMENT_NODE