pseudo-dom
    Preparing search index...

    Class NodeService

    Simulate the behaviour of the Node Class when there is no DOM available.

    Hierarchy (View Summary)

    Implements

    Index
    childList: PseudoNodeList | LinkedTreeList

    The raw list of every child node (all types), used to implement childNodes/firstChild/lastChild/insertBefore/removeChild. Not the same thing as Element.children (an HTMLCollection of just the element children).

    listLinker: TreeLinker

    The linker which holds this node in the children list of its parent, from which its siblings are found (null while it has no parent).

    nodeNameValue: string
    ownerDocumentStore: PseudoDocument

    The document which made this node (createElement and the like), for when it is not in a tree yet.

    parent: PseudoNode
    ATTRIBUTE_NODE: 2
    CDATA_SECTION_NODE: 4
    COMMENT_NODE: 8
    DEFAULT_NODE: 0
    DOCUMENT_FRAGMENT_NODE: 11
    DOCUMENT_NODE: 9
    DOCUMENT_POSITION_CONTAINED_BY: 16
    DOCUMENT_POSITION_CONTAINS: 8
    DOCUMENT_POSITION_DISCONNECTED: 1
    DOCUMENT_POSITION_FOLLOWING: 4
    DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32
    DOCUMENT_POSITION_PRECEDING: 2
    DOCUMENT_TYPE_NODE: 10
    ELEMENT_NODE: 1
    ENTITY_NODE: 6
    ENTITY_REFERENCE_NODE: 5
    NOTATION_NODE: 12
    PROCESSING_INSTRUCTION_NODE: 7
    TEXT_NODE: 3
    • get acceptsChildren(): boolean

      Whether this kind of node can have children (text, comments and attributes cannot).

      Returns boolean

    • get baseURI(): string | Location

      Returns a string representing the base URL of the document containing the Node.

      Returns string | Location

    • get childNodes(): PseudoNodeList | LinkedTreeList

      Returns a live NodeList containing all the children of this node (including elements, text and comments). NodeList being live means that if the children of the Node change, the NodeList object is automatically updated.

      Returns PseudoNodeList | LinkedTreeList

    • get isConnected(): boolean

      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.

      Returns boolean

    • get nodeName(): string

      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.

      Returns string

    • get nodeType(): number

      Returns an unsigned short representing the type of the node. Possible values are:


      | Name | Value | |---------------------------------------- | ELEMENT_NODE | 1 | | ATTRIBUTE_NODE | 2 | | TEXT_NODE | 3 | | CDATA_SECTION_NODE | 4 | | PROCESSING_INSTRUCTION_NODE | 7 | | COMMENT_NODE | 8 | | DOCUMENT_NODE | 9 | | DOCUMENT_TYPE_NODE | 10 | | DOCUMENT_FRAGMENT_NODE | 11 |

      Returns number

    • get nodeValue(): string

      Returns the value of the current node.

      Returns string

    • set nodeValue(value: string): void

      Returns the value of the current node.

      Parameters

      • value: string

      Returns void

    • get parentElement(): PseudoElement

      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.

      Returns PseudoElement

    • get parentNode(): PseudoNode

      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.

      Returns PseudoNode

    • get textContent(): string

      Returns the textual content of an element and all its descendants.

      Returns string

    • set textContent(text: string): void

      Returns the textual content of an element and all its descendants.

      Parameters

      • text: string

      Returns void

    • Registers an event handler of a specific event type. Adding the same handler again for the same type and phase does nothing, like the DOM.

      Parameters

      • type: string

        The type of event to listen for

      • callback: any

        The function to call (or an object with a handleEvent function)

      • useCapture: boolean | listenerOptions = false

        Listen while the event travels down to the target (true), or an object with capture, once and passive

      Returns void

    • Add nodes (strings become text nodes) as this node's next siblings, in order. Does nothing when this node has no parent.

      Parameters

      • ...nodes: (string | PseudoNode)[]

        The nodes (or text) to add

      Returns void

    • Add nodes (strings become text nodes) as the last children of this node, in the order given.

      Parameters

      • ...nodes: (string | PseudoNode)[]

        The nodes (or text) to add

      Returns void

      When this kind of node cannot have children

    • Add nodes (strings become text nodes) as this node's previous siblings, in order. Does nothing when this node has no parent.

      Parameters

      • ...nodes: (string | PseudoNode)[]

        The nodes (or text) to add

      Returns void

    • Called each time a node has been inserted as a child of this node, so that nodes which need to react to children (for example elements applying default events) can do so.

      Parameters

      Returns void

    • Make a copy of this node without its children, its parent or its listeners, which is what cloneNode starts from. Kinds of node which are made with arguments override this to give them.

      Returns NodeService

    • Say where another node is in relation to this one, as the bits of NodeService.DOCUMENT_POSITION_*: 0 for this node itself, DISCONNECTED (with IMPLEMENTATION_SPECIFIC and a consistent PRECEDING or FOLLOWING) for a node in another tree, CONTAINS + PRECEDING when the other node is an ancestor, CONTAINED_BY + FOLLOWING when it is a descendant, otherwise PRECEDING or FOLLOWING by their order in the tree.

      Parameters

      Returns number

    • Dispatches an event to this target and through the tree: capture listeners of the ancestors from the root down, then the listeners of this target, then (when the event bubbles) the other listeners of the ancestors from the parent up to the root. stopPropagation() stops it reaching further targets, stopImmediatePropagation() also stops the remaining listeners of the current target. Afterwards, unless the default was prevented, the default action of this target (see setDefaultEvent) runs. The event can be dispatched again afterwards.

      Parameters

      Returns boolean

      False when the event was cancelable and a listener prevented the default, otherwise true

      When the event is already being dispatched, or (after the whole dispatch has finished) the error which a listener threw (an error with all of them in its errors property when several did)

    • Whether another node of the same type is equal to this one apart from its children, which isEqualNode compares afterwards. Kinds of node with more to compare (an element has attributes) override this.

      Parameters

      Returns boolean

    • Every element below this node with the given tag name, live. There is no real namespace parsing here, so this ignores the namespace and behaves exactly like getElementsByTagName.

      Parameters

      • namespace: string

        Ignored

      • tagName: string

      Returns HTMLCollectionService

    • Accepts a namespace URI as an argument and returns a boolean value with a value of true if the namespace is the default namespace on the given node or false if not.

      Parameters

      • namespaceURI: string

      Returns boolean

    • Whether another node is the same as this one, by what they hold: the same type, name and value (an element also needs the same attributes), and children which are equal in the same order.

      Parameters

      Returns boolean

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

      Parameters

      • prefix: string

      Returns string

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

      Parameters

      • namespace: string

      Returns string

    • Add nodes (strings become text nodes) as the first children of this node, in the order given.

      Parameters

      • ...nodes: (string | PseudoNode)[]

        The nodes (or text) to add

      Returns void

      When this kind of node cannot have children

    • Every element below this node which matches the CSS selector, in tree order. A plain array (not a live collection): like the DOM's querySelectorAll, it is a snapshot taken when it is called.

      Parameters

      • selectors: string

        A CSS selector

      Returns PseudoElement[]

    • Remove every child of this node and put the given nodes (strings become text nodes) in their place, in order.

      Parameters

      • ...nodes: (string | PseudoNode)[]

        The nodes (or text) to add

      Returns void

      When this kind of node cannot have children

    • Put the given nodes (strings become text nodes) where this node is, in order, then remove this node. Does nothing when this node has no parent.

      Parameters

      • ...nodes: (string | PseudoNode)[]

        The nodes (or text) to put in this node's place

      Returns void