A general element

An element can be a NativeNode , a Component , or a VirtualNode .

Hierarchy (view full)

Constructors

Properties

Accessors

Methods

Constructors

Properties

[ELEMENT_SYMBOL]: true
[NATIVE_NODE_SYMBOL]: true
childNodes: Node[]

The child nodes (must not be modified directly!)

classList: null | ClassList

The ClassList of the element (will never change and must not be modified!)

containingSlot: undefined | null | glassEasel.Element

The parent slot element in composed tree (must not be modified directly!)

dataset: {
    [name: string]: unknown;
}

Type declaration

  • [name: string]: unknown
is: string
ownerShadowRoot: null | ShadowRoot

The shadow-root which owns the element (will never change and must not be modified!)

parentIndex: number

The index in parentNode.childNodes (-1 if no parentNode) (must not be modified directly!)

parentNode: null | glassEasel.Element

The parent element (must not be modified directly!)

slotIndex: undefined | number

The index in containingSlot.slotNodes (must not be modified directly!)

slotNodes: undefined | Node[]

The slot content nodes composed tree (must not be modified directly!)

stylingName: string
isElement: ((e) => e is glassEasel.Element)

Type declaration

isNativeNode: ((e) => e is NativeNode)

Type declaration

Accessors

  • get attributes(): {
        name: string;
        value: unknown;
    }[]
  • Returns {
        name: string;
        value: unknown;
    }[]

  • get class(): string
  • Returns string

  • set class(classNames): void
  • Parameters

    • classNames: string

    Returns void

  • get id(): string
  • Returns string

  • set id(x): void
  • Parameters

    • x: unknown

    Returns void

  • get slot(): string
  • Returns string

  • set slot(x): void
  • Parameters

    • x: string

    Returns void

  • get style(): string
  • Returns string

  • set style(styleText): void
  • Parameters

    • styleText: string

    Returns void

Methods

  • Add an event listener on the element

    Parameters

    Returns void

  • Parameters

    Returns void

  • Cast a node to an element (native node, virtual node, or component node)

    Returns null if the element is not a text node.

    Returns glassEasel.Element

  • Cast an element to a native node

    Returns null if the element is not a native node.

    Returns null | NativeNode

  • Cast an element to a shadow root

    Returns null if the element is not a shadow root.

    Returns null | ShadowRoot

  • Cast a node to a text node

    Returns null if the element is not a text node.

    Returns null

  • Cast an element to a virtual node

    Returns null if the element is not a virtual node.

    Returns null | VirtualNode

  • Cancel the destroy scheduling of the backend element

    Returns void

    Deprecated

    Use cancelDestroyBackendElementOnRemoval instead.

  • Cancel the destroy scheduling of the backend element

    Returns void

  • Collect the marks on the element

    The marks includes the marks on ancestors (in shadow tree) of the element. If multiple marks on different elements shares the same name, the mark value on the child-most element is accepted.

    Returns {
        [name: string]: unknown;
    }

    • [name: string]: unknown
  • Create an intersection observer

    The relativeElement is the element to calculate intersection with ( null for the viewport). The relativeElementMargin is the margins of the relativeElement . The thresholds is a list of intersection ratios to trigger the listener . The listener always triggers once immediately after this call.

    Parameters

    • relativeElement: null | glassEasel.Element
    • relativeElementMargin: string
    • thresholds: number[]
    • listener: ((res) => void)
        • (res): void
        • Parameters

          • res: IntersectionStatus

          Returns void

    Returns null | Observer

  • Destroy the backend element

    It only destroy the backend element of the element itself.

    Returns void

  • Destroy the backend element when removed from any parent element

    Returns void

    Deprecated

    Use destroyBackendElementOnRemoval instead.

  • Destroy the backend element when removed from any parent element

    Returns void

  • Destroy backend element for the whole subtree.

    It will destroy backend elements for the whole subtree (shadow tree) recursively. If a backend element for a component is destroyed, any backend element in the shadow tree of the component will also be destroyed.

    Returns void

  • Trigger an event with specified event object on the element

    Parameters

    Returns void

  • Iterate composed child nodes (including virtual nodes)

    if f returns false then the iteration is interrupted. Returns true if that happens.

    Parameters

    • f: ((node) => boolean | void)
        • (node): boolean | void
        • Parameters

          Returns boolean | void

    Returns boolean

  • Iterate non-virtual composed child nodes

    if f returns false then the iteration is interrupted. Returns true if that happens.

    Parameters

    • f: ((node) => boolean | void)
        • (node): boolean | void
        • Parameters

          Returns boolean | void

    Returns boolean

  • Get an attribute value ( null if not set or removed)

    Parameters

    • name: string

    Returns unknown

  • Get the bounding client rect

    Return zero values when the backend element is invalid or it does not have layout information.

    Parameters

    Returns void

  • Get the composed children

    This method always returns a new array. It is convenient but less performant. For better performance, consider using forEachComposedChild .

    Returns Node[]

  • Get an interactive context

    Parameters

    • cb: ((res) => void)
        • (res): void
        • Parameters

          • res: unknown

          Returns void

    Returns void

  • Returns {
        [name: string]: ModelBindingListener;
    }

    • [name: string]: ModelBindingListener
  • Get the bounding client rect

    Return zero values when the backend element is invalid or it does not have layout information.

    Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    • child: Node
    • index: number

    Returns void

  • Parameters

    • children: Node[]
    • index: number

    Returns void

  • Get whether the slot-inherit mode is set or not

    Returns boolean

  • Get whether the node is virtual or not

    Returns boolean

  • Iterate composed child nodes (including virtual nodes)

    if f returns false then the iteration is interrupted. Returns true if that happens.

    Returns Generator<Node, void, void>

  • Test whether the target in this subtree matches the selector

    Parameters

    Returns boolean

  • Remove an attribute

    Parameters

    • name: string

    Returns void

  • Parameters

    Returns void

  • Parameters

    • index: number

    Returns void

  • Parameters

    • index: number
    • count: number

    Returns void

  • Parameters

    Returns void

  • Parameters

    • child: Node
    • index: number

    Returns void

  • Set an attribute value

    Parameters

    • name: string
    • value: unknown

    Returns void

  • Set a dataset on the element

    Parameters

    • name: string
    • value: unknown

    Returns void

  • Set a mark on the element

    Parameters

    • name: string
    • value: unknown

    Returns void

  • Parameters

    • propName: string
    • listener: ModelBindingListener

    Returns void

  • Set the node class

    Parameters

    Returns void

  • Set the node style

    Parameters

    Returns void

  • Toggle the node class

    Parameters

    Returns void

  • Trigger an event on the element

    Parameters

    • name: string
    • Optional detail: unknown
    • Optional options: EventOptions

    Returns void

  • Update an attribute value

    Parameters

    • name: string
    • value: unknown

    Returns void

  • Parameters

    Returns void

  • Iterate elements with their slots (slots-inherited nodes included)

    Parameters

    • node: Node
    • f: ((node, slot) => boolean | void)
        • (node, slot): boolean | void
        • Parameters

          Returns boolean | void

    Returns boolean

  • Iterate elements in specified slot (slots-inherited nodes included)

    Parameters

    • node: Node
    • slot: undefined | null | glassEasel.Element
    • f: ((node) => boolean | void)
        • (node): boolean | void
        • Parameters

          Returns boolean | void

    Returns boolean

  • Iterate elements with their slots (slots-inherited nodes NOT included)

    Parameters

    • node: Node
    • f: ((node, slot) => boolean | void)
        • (node, slot): boolean | void
        • Parameters

          Returns boolean | void

    Returns boolean

  • Iterate elements in specified slot (slots-inherited nodes NOT included)

    Parameters

    • node: Node
    • slot: undefined | null | glassEasel.Element
    • f: ((node) => boolean | void)
        • (node): boolean | void
        • Parameters

          Returns boolean | void

    Returns boolean

  • Get whether the slot-inherit mode is set or not

    Parameters

    Returns boolean

  • Get the slot name of the element

    Parameters

    Returns undefined | string

  • Get whether a node has any subtree MutationObserver attached to it

    If there is, then tree update may have more performance impact.

    Parameters

    Returns boolean

  • Check the element is attached or not

    Parameters

    Returns boolean

  • Test whether the target matches the selector

    Parameters

    Returns boolean

  • Make the element looks like attached.

    If the element will never be attached to backend or it has no backend element at all, this can be used to trigger attached life-time.

    Parameters

    Returns void

  • Make the element looks like detached.

    This can be used to trigger detached life-time without remove the element in the backend.

    Parameters

    Returns void

  • Attach the element into the backend, swapping out a placeholder element in the backend.

    The element must not be a child node of another element, must not be attached before, and must not have a ownerShadowRoot . The element targetParent and targetNode must be in the same backend context. The element replaces the targetNode in the targetParent .

    Parameters

    Returns void

  • Set the virtual node to slot-inherit mode

    In slot-inherit mode of an element, the child nodes of the element will be treated as siblings and can have different target slot.

    Parameters

    Returns void

  • Set the binding slot of specific node

    Necessary if node belongs to a dynamic slot, which cannot be identified by slot name.

    Parameters

    Returns void

  • Set the slot name of the element

    Once this method is called for an element , it will be treated as a slot which can contain child nodes in composed tree. This method should not be used in components, otherwise the slot content will always be dangled.

    Parameters

    Returns void