pseudo-dom
    Preparing search index...

    Class ElementService

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

    Hierarchy (View Summary)

    Implements

    Index
    • Parameters

      • settings: {
            attributes?: attribute[];
            children?: any[];
            parent?: PseudoNode;
            tagName?: string;
        } = {}
        • Optionalattributes?: attribute[]

          The attributes (also assigned as properties) to start with

        • Optionalchildren?: any[]

          The nodes to start as children

        • Optionalparent?: PseudoNode

          The node to add this element to as its last child

        • OptionaltagName?: string

          The name of the tag this element represents

      Returns ElementService

    animations: any[] = []

    What getAnimations() returns - set this directly.

    boundingClientRect: DOMRect = ...

    What getBoundingClientRect() returns - not really computed (there is no layout engine), set this directly.

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

    clientHeight: number

    Returns a number representing the inner height of the element.

    clientLeft: number

    Returns a number representing the width of the left border of the element.

    clientRects: DOMRect[] = []

    What getClientRects() returns - set this directly.

    clientTop: number

    Returns a number representing the width of the top border of the element.

    clientWidth: number

    Returns a number representing the inner width of the element.

    id: string

    A string representing the id of the element.

    isVisible: boolean = true

    What checkVisibility() returns - set this directly.

    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
    scrollHeight: number

    Returns a number representing the scroll view height of an element.

    scrollLeft: number

    A number representing the left scroll offset of the element.

    scrollTop: number

    A number representing number of pixels the top of the element is scrolled vertically.

    scrollWidth: number

    Returns a number representing the scroll view width of the element.

    type: string
    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 ariaAtomic(): string

      A string reflecting the aria-atomic attribute, which indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute.

      Returns string

    • set ariaAtomic(value: string): void

      A string reflecting the aria-atomic attribute, which indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute.

      Parameters

      • value: string

      Returns void

    • get ariaAutoComplete(): string

      A string reflecting the aria-autocomplete attribute, which indicates whether inputting text could trigger display of one or more predictions of the user's intended value for a combobox, searchbox, or textbox and specifies how predictions would be presented if they were made.

      Returns string

    • set ariaAutoComplete(value: string): void

      A string reflecting the aria-autocomplete attribute, which indicates whether inputting text could trigger display of one or more predictions of the user's intended value for a combobox, searchbox, or textbox and specifies how predictions would be presented if they were made.

      Parameters

      • value: string

      Returns void

    • get ariaBusy(): string

      A string reflecting the aria-busy attribute, which indicates whether an element is being modified, as assistive technologies may want to wait until the modifications are complete before exposing them to the user.

      Returns string

    • set ariaBusy(value: string): void

      A string reflecting the aria-busy attribute, which indicates whether an element is being modified, as assistive technologies may want to wait until the modifications are complete before exposing them to the user.

      Parameters

      • value: string

      Returns void

    • get ariaChecked(): string

      A string reflecting the aria-checked attribute, which indicates the current "checked" state of checkboxes, radio buttons, and other widgets that have a checked state.

      Returns string

    • set ariaChecked(value: string): void

      A string reflecting the aria-checked attribute, which indicates the current "checked" state of checkboxes, radio buttons, and other widgets that have a checked state.

      Parameters

      • value: string

      Returns void

    • get ariaColIndex(): string

      A string reflecting the aria-colindex attribute, which defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.

      Returns string

    • set ariaColIndex(value: string): void

      A string reflecting the aria-colindex attribute, which defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.

      Parameters

      • value: string

      Returns void

    • get ariaColSpan(): string

      A string reflecting the aria-colspan attribute, which defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.

      Returns string

    • set ariaColSpan(value: string): void

      A string reflecting the aria-colspan attribute, which defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.

      Parameters

      • value: string

      Returns void

    • get ariaCurrent(): string

      A string reflecting the aria-current attribute, which indicates the element that represents the current item within a container or set of related elements.

      Returns string

    • set ariaCurrent(value: string): void

      A string reflecting the aria-current attribute, which indicates the element that represents the current item within a container or set of related elements.

      Parameters

      • value: string

      Returns void

    • get ariaDisabled(): string

      A string reflecting the aria-disabled attribute, which indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.

      Returns string

    • set ariaDisabled(value: string): void

      A string reflecting the aria-disabled attribute, which indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.

      Parameters

      • value: string

      Returns void

    • get ariaExpanded(): string

      A string reflecting the aria-expanded attribute, which indicates whether a grouping element owned or controlled by this element is expanded or collapsed.

      Returns string

    • set ariaExpanded(value: string): void

      A string reflecting the aria-expanded attribute, which indicates whether a grouping element owned or controlled by this element is expanded or collapsed.

      Parameters

      • value: string

      Returns void

    • get ariaHasPopup(): string

      A string reflecting the aria-haspopup attribute, which indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.

      Returns string

    • set ariaHasPopup(value: string): void

      A string reflecting the aria-haspopup attribute, which indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.

      Parameters

      • value: string

      Returns void

    • get ariaKeyShortcuts(): string

      A string reflecting the aria-keyshortcuts attribute, which indicates keyboard shortcuts that an author has implemented to activate or give focus to an element.

      Returns string

    • set ariaKeyShortcuts(value: string): void

      A string reflecting the aria-keyshortcuts attribute, which indicates keyboard shortcuts that an author has implemented to activate or give focus to an element.

      Parameters

      • value: string

      Returns void

    • get ariaLive(): string

      A string reflecting the aria-live attribute, which indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region.

      Returns string

    • set ariaLive(value: string): void

      A string reflecting the aria-live attribute, which indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region.

      Parameters

      • value: string

      Returns void

    • get ariaRowIndex(): string

      A string reflecting the aria-rowindex attribute, which defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.

      Returns string

    • set ariaRowIndex(value: string): void

      A string reflecting the aria-rowindex attribute, which defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.

      Parameters

      • value: string

      Returns void

    • get ariaRowSpan(): string

      A string reflecting the aria-rowspan attribute, which defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.

      Returns string

    • set ariaRowSpan(value: string): void

      A string reflecting the aria-rowspan attribute, which defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.

      Parameters

      • value: string

      Returns void

    • get ariaSort(): string

      A string reflecting the aria-sort attribute, which indicates if items in a table or grid are sorted in ascending or descending order.

      Returns string

    • set ariaSort(value: string): void

      A string reflecting the aria-sort attribute, which indicates if items in a table or grid are sorted in ascending or descending order.

      Parameters

      • value: string

      Returns void

    • 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 innerHTML(): string

      The HTML markup of this element's children. Only the getter is here (the setter, which needs to build new elements from parsed HTML, is on HTMLElementService - see its class comment).

      Returns string

    • 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

    • 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

    • 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

    • A read-only view of the element's own inline style declarations (there is no CSS cascade here, so this is not a real computed style - just what the element's own style object holds).

      Returns { get: (property: string) => string }

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

    • Retrieve the node representation of an attribute. There is no real namespace parsing here, so this ignores the namespace and behaves exactly like getAttributeNode.

      Parameters

      • namespace: string

        Ignored

      • attributeName: string

      Returns AttrService

      An Attr for the attribute, or null when there is no such attribute

    • Retrieve the value of an attribute. There is no real namespace parsing here, so this ignores the namespace and behaves exactly like getAttribute.

      Parameters

      • namespace: string

        Ignored

      • attributeName: string

      Returns string

      The value, or null when there is no such attribute

    • Check whether the element has an attribute by that name. There is no real namespace parsing here, so this ignores the namespace and behaves exactly like hasAttribute.

      Parameters

      • namespace: string

        Ignored

      • attributeName: string

      Returns boolean

    • Put an element at a position relative to this one: beforebegin (before this element, as its previous sibling), afterbegin (as this element's first child), beforeend (as this element's last child) or afterend (after this element, as its next sibling).

      Parameters

      • position: string

        beforebegin, afterbegin, beforeend or afterend

      • element: PseudoElement

        The element to insert

      Returns PseudoElement

      The inserted element, or null when the position needed a parent this element does not have

      When the position is not one of the four above

    • Not implemented yet (HTML parsing is out of scope for now).

      Parameters

      • position: string

        beforebegin, afterbegin, beforeend or afterend

      • text: string

        The markup which would be parsed

      Returns void

    • Put text at a position relative to this element, the same as insertAdjacentElement but the text becomes a text node.

      Parameters

      • position: string

        beforebegin, afterbegin, beforeend or afterend

      • text: string

        The text to insert

      Returns void

      When the position is not one of the four above

    • 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

    • Remove an attribute from the element. There is no real namespace parsing here, so this ignores the namespace and behaves exactly like removeAttribute.

      Parameters

      • namespace: string

        Ignored

      • attributeName: string

      Returns void

    • Scroll to the given position (or, given an options object, the position(s) it has). There is no real scrollable viewport here: this just sets scrollLeft / scrollTop.

      Parameters

      • x: number | { left?: number; top?: number } = 0
      • y: number = 0

      Returns void

    • Scroll by the given amount, relative to the current position.

      Parameters

      • x: number | { left?: number; top?: number } = 0
      • y: number = 0

      Returns void

    • Scroll an ancestor until this element is in view. There is no real viewport here for that to mean anything, so this does nothing (override it on an instance in a test which needs to observe the call).

      Returns void

    • Scroll to the given position. An alias for scroll.

      Parameters

      • x: number | { left?: number; top?: number } = 0
      • y: number = 0

      Returns void

    • Set the value of an attribute, adding the attribute if it did not exist.

      Parameters

      • attributeName: string
      • attributeValue: string

      Returns void

    • Set the value of an attribute, adding the attribute if it did not exist. There is no real namespace parsing here, so this ignores the namespace and behaves exactly like setAttribute.

      Parameters

      • namespace: string

        Ignored

      • attributeName: string
      • attributeValue: string

      Returns void

    • Add the attribute (with an empty value) when it is not present, or remove it when it is - unless force says which of those to do instead. Returns whether the attribute is present after the call.

      Parameters

      • attributeName: string
      • Optionalforce: boolean

      Returns boolean