turbodombuilder - v0.9.5
    Preparing search index...

    Class TurboSelector<Type>

    Type Parameters

    Hierarchy

    Index

    Constructors

    Properties

    boundListeners: Set<ListenerEntry>

    Readonly set of listeners bound to this node.

    bypassManagerOn: (e: Event) => boolean | TurboEventManagerStateProperties

    Type Declaration

    If you want the element to bypass the event manager and allow native events to seep through, you can set this field to a predicate that defines when to bypass the manager.

    childHandler: ChildHandler

    The child handler object associated with the node. It is the node itself (if it is handling its children) or its shadow root (if defined). Set it to change the node where the children are added/ removed/queried from when manipulating the node's children.

    childNodesArray: Node[]

    Static array of all the child nodes of the node.

    childrenArray: Element[]

    Static array of all the child elements of the node.

    siblingNodes: Node[]

    Static array of all the sibling nodes (including the node itself) of the node.

    siblings: Element[]

    Static array of all the sibling elements (including the element itself, if it is one) of the node.

    reifects: ReifectHandler

    Handler for all Reifects attached to this element.

    showTransition: StatefulReifect<Shown>

    The transition used by the element's show() and isShown methods. Directly modifying its value will modify all elements' default showTransition. Unless this is the desired outcome, set it to a new custom StatefulReifect.

    isShown: boolean

    Boolean indicating whether the element is shown or not, based on its showTransition.

    closestRoot: StylesRoot

    The closest root to the element in the document (the closest ShadowRoot, or the document's head).

    currentSubstrate: string
    onSubstrateChange: Delegate<(prev: string, next: string) => void>
    element: Type

    Methods

    • Parameters

      • Optionalclasses: string | string[]

        String of classes separated by spaces, or array of strings.

      Returns this

      Itself, allowing for method chaining.

      Add one or more CSS classes to the element.

    • Parameters

      • Optionalclasses: string | string[]

        String of classes separated by spaces, or array of strings.

      Returns this

      Itself, allowing for method chaining.

      Remove one or more CSS classes from the element.

    • Parameters

      • Optionalclasses: string | string[]

        String of classes separated by spaces, or array of strings.

      • Optionalforce: boolean

        (Optional) Boolean that turns the toggle into a one way-only operation. If set to false, then the class will only be removed, but not added. If set to true, then token will only be added, but not removed.

      Returns this

      Itself, allowing for method chaining.

      Toggle one or more CSS classes in the element.

    • Parameters

      • Optionalclasses: string | string[]

        String of classes separated by spaces, or array of strings

      Returns boolean

      A boolean indicating whether the provided classes are included

      Check if the element's class list contains the provided class(es).

    • Sets the declared properties to the element.

      Type Parameters

      • Tag extends
            | "symbol"
            | "filter"
            | "set"
            | "animate"
            | "animateMotion"
            | "animateTransform"
            | "circle"
            | "clipPath"
            | "defs"
            | "desc"
            | "ellipse"
            | "feBlend"
            | "feColorMatrix"
            | "feComponentTransfer"
            | "feComposite"
            | "feConvolveMatrix"
            | "feDiffuseLighting"
            | "feDisplacementMap"
            | "feDistantLight"
            | "feDropShadow"
            | "feFlood"
            | "feFuncA"
            | "feFuncB"
            | "feFuncG"
            | "feFuncR"
            | "feGaussianBlur"
            | "feImage"
            | "feMerge"
            | "feMergeNode"
            | "feMorphology"
            | "feOffset"
            | "fePointLight"
            | "feSpecularLighting"
            | "feSpotLight"
            | "feTile"
            | "feTurbulence"
            | "foreignObject"
            | "g"
            | "image"
            | "line"
            | "linearGradient"
            | "marker"
            | "mask"
            | "metadata"
            | "mpath"
            | "path"
            | "pattern"
            | "polygon"
            | "polyline"
            | "radialGradient"
            | "rect"
            | "stop"
            | "svg"
            | "switch"
            | "text"
            | "textPath"
            | "tspan"
            | "use"
            | "view"
            | (keyof HTMLElementTagNameMap)
            | (keyof MathMLElementTagNameMap)
            | (keyof TurboElementTagNameMap)

      Parameters

      • properties: TurboProperties<Tag>

        The properties object.

      • OptionalsetOnlyBaseProperties: boolean

        If set to true, will only set the base turbo properties (classes, text, style, id, children, parent, etc.) and ignore all other properties not explicitly defined in TurboProperties.

      Returns this

      Itself, allowing for method chaining.

    • Returns this

      Itself, allowing for method chaining.

      Destroys the node by removing it from the document and removing all its bound listeners.

    • Parameters

      • name: string

        The name of the attribute.

      • Optionalvalue: string | number | boolean

        The value of the attribute. Can be left blank to represent a true boolean.

      Returns this

      Itself, allowing for method chaining.

      Sets the value of an attribute on the underlying element.

    • Parameters

      • name: string

        The name of the attribute to remove.

      Returns this

      Itself, allowing for method chaining.

      Removes an attribute from the underlying element.

    • Returns this

      Itself, allowing for method chaining.

      Causes the element to lose focus.

    • Returns this

      Itself, allowing for method chaining.

      Sets focus on the element.

    • Type Parameters

      Parameters

      • type: string

        The type of the event.

      • listener: (e: Event, el: Type) => boolean | void

        The function that receives a notification.

      • Optionaloptions: AddEventListenerOptions

        An options object that specifies characteristics about the event listener.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns this

      Itself, allowing for method chaining.

      Adds an event listener to the element.

    • Type Parameters

      Parameters

      • type: string

        The type of the event.

      • toolName: string

        The name of the tool. Set to null or undefined to check for listeners not bound to a tool.

      • listener: (e: Event, el: Type) => boolean | void

        The function that receives a notification.

      • Optionaloptions: AddEventListenerOptions

        An options object that specifies characteristics about the event listener.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns this

      Itself, allowing for method chaining.

      Adds an event listener to the element.

    • Parameters

      • type: string
      • toolName: string
      • event: Event
      • Optionaloptions: AddEventListenerOptions
      • Optionalmanager: TurboEventManager

      Returns boolean

    • Parameters

      • type: string

        The type of the event. Set to null or undefined to get all event types.

      • listener: (e: Event, el: this) => boolean | void

        The function that receives a notification.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns boolean

      • Whether the element has the given listener.

      Checks if the given event listener is bound to the element (in its boundListeners list).

    • Parameters

      • type: string

        The type of the event. Set to null or undefined to get all event types.

      • toolName: string

        The name of the tool the listener is attached to. Set to null or undefined to check for listeners not bound to a tool.

      • listener: (e: Event, el: this) => boolean | void

        The function that receives a notification.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns boolean

      • Whether the element has the given listener.

      Checks if the given event listener is bound to the element (in its boundListeners list).

    • Parameters

      • type: string

        The type of the event. Set to null or undefined to get all event types.

      • OptionaltoolName: string

        The name of the tool to consider (if any). Set to null or undefined to check for listeners not bound to a tool.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns boolean

      • Whether the element has the given listener.

      Checks if the element has bound listeners of the given type (in its boundListeners list).

    • Parameters

      • type: string

        The type of the event.

      • listener: (e: Event, el: this) => boolean | void

        The function that receives a notification.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns this

      Itself, allowing for method chaining.

      Removes an event listener that is bound to the element (in its boundListeners list).

    • Parameters

      • type: string

        The type of the event.

      • toolName: string

        The name of the tool the listener is attached to. Set to null or undefined to check for listeners not bound to a tool.

      • listener: (e: Event, el: this) => boolean | void

        The function that receives a notification.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns this

      Itself, allowing for method chaining.

      Removes an event listener that is bound to the element (in its boundListeners list).

    • Parameters

      • type: string

        The type of the event. Set to null or undefined to consider all types.

      • OptionaltoolName: string

        The name of the tool associated (if any). Set to null or undefined to check for listeners not bound to a tool.

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns this

      Itself, allowing for method chaining.

      Removes all event listeners bound to the element (in its boundListeners list) assigned to the specified type.

    • Parameters

      • Optionalmanager: TurboEventManager

        The associated event manager. Defaults to the first created manager, or a new instantiated one if none already exist.

      Returns this

      Itself, allowing for method chaining.

      Removes all event listeners bound to the element (in its boundListeners list).

    • Parameters

      Returns this

      Prevent default browser behavior on the provided event types. By default, all basic input events will be processed.

    • Returns this

    • Returns this

    • Returns this

      Itself, allowing for method chaining.

      Removes the node from the document.

    • Returns this

      Itself, allowing for method chaining.

      Removes the element from the document.

    • Parameters

      • Optionalparent: Node

        Array of (or single) child nodes.

      • Optionalindex: number

        The position at which to add the child relative to the parent's child list. Leave undefined to add the child at the end.

      • OptionalreferenceList: Node[] | NodeListOf<Node>

        The child list to use as computation reference for index placement. Defaults to the node's childrenArray.

      Returns this

      Itself, allowing for method chaining.

      Add one or more children to the referenced parent node.

    • Parameters

      • Optionalchildren: Node | Node[]

        Array of (or single) child nodes.

      • Optionalindex: number

        The position at which to add the child relative to the parent's child list. Leave undefined to add the child at the end.

      • OptionalreferenceList: Node[] | NodeListOf<Node>

        The child list to use as computation reference for index placement. Defaults to the node's childrenArray.

      Returns this

      Itself, allowing for method chaining.

      Add one or more children to the referenced parent node.

    • Parameters

      • Optionalchildren: Node | Node[]

        Array of (or single) child nodes.

      Returns this

      Itself, allowing for method chaining.

      Remove one or more children from the referenced parent node.

    • Parameters

      • Optionalchildren: Node | Node[]

        Array of (or single) child nodes to insert before sibling.

      • Optionalsibling: Node

        The sibling node to insert the children before.

      Returns this

      Itself, allowing for method chaining.

      Add one or more children to the referenced parent node before the provided sibling. If the sibling is not found in the parent's children, the nodes will be added to the end of the parent's child list.

    • Parameters

      • Optionalindex: number

        The index of the child(ren) to remove.

      • Optionalcount: number

        The number of children to remove.

      • OptionalreferenceList: Node[] | NodeListOf<Node>

        The child list to use as computation reference for index placement and count. Defaults to the node's childrenArray.

      Returns this

      Itself, allowing for method chaining.

      Remove one or more child nodes from the referenced parent node.

    • Parameters

      • OptionalreferenceList: Node[] | NodeListOf<Node>

        The child list to representing all the nodes to remove. Defaults to the node's childrenArray.

      Returns this

      Itself, allowing for method chaining.

      Remove all children of the node.

    • Type Parameters

      Parameters

      • Optionalindex: number

        The index of the child to retrieve.

      • OptionalreferenceList: NodeListOf<ChildType> | ChildType[]

        The child list to use as computation reference for index placement. Defaults to the node's childrenArray.

      Returns ChildType

      The child at the given index, or null if the index is invalid.

      Returns the child of the parent node at the given index. Any number inputted (including negatives) will be reduced modulo length of the list size.

    • Parameters

      • Optionalchild: Node

        The child element to find.

      • OptionalreferenceList: Node[] | NodeListOf<Node>

        The child list to use as computation reference for index placement. Defaults to the node's childrenArray.

      Returns number

      The index of the child node in the provided list, or -1 if the child is not found.

      Returns the index of the given child.

    • Parameters

      • Optionalchildren: Node | Node[]

        Array of (or single) child nodes.

      Returns boolean

      A boolean indicating whether the provided nodes belong to the parent or not.

      Identify whether one or more children belong to this parent node.

    • Parameters

      • Optionalchildren: Node | Node[]

        The child or children to check.

      Returns boolean

      True if the children belong to the node, false otherwise.

      Finds whether one or more children belong to this node.

    • Parameters

      • Optionalparents: Node | Node[]

        The parent(s) to check.

      Returns boolean

      True if the node is within the given parents, false otherwise.

      Finds whether this node is within the given parent(s).

    • Parameters

      • OptionalreferenceList: Node[]

        The siblings list to use as computation reference for index placement. Defaults to the node's siblings.

      Returns number

      True if the children belong to the node, false otherwise.

      Finds whether one or more children belong to this node.

    • Finds the closest ancestor of the current element (or the current element itself) that matches the provided CSS selector or element type.

      Type Parameters

      • Type extends
            | "symbol"
            | "filter"
            | "set"
            | "animate"
            | "animateMotion"
            | "animateTransform"
            | "circle"
            | "clipPath"
            | "defs"
            | "desc"
            | "ellipse"
            | "feBlend"
            | "feColorMatrix"
            | "feComponentTransfer"
            | "feComposite"
            | "feConvolveMatrix"
            | "feDiffuseLighting"
            | "feDisplacementMap"
            | "feDistantLight"
            | "feDropShadow"
            | "feFlood"
            | "feFuncA"
            | "feFuncB"
            | "feFuncG"
            | "feFuncR"
            | "feGaussianBlur"
            | "feImage"
            | "feMerge"
            | "feMergeNode"
            | "feMorphology"
            | "feOffset"
            | "fePointLight"
            | "feSpecularLighting"
            | "feSpotLight"
            | "feTile"
            | "feTurbulence"
            | "foreignObject"
            | "g"
            | "image"
            | "line"
            | "linearGradient"
            | "marker"
            | "mask"
            | "metadata"
            | "mpath"
            | "path"
            | "pattern"
            | "polygon"
            | "polyline"
            | "radialGradient"
            | "rect"
            | "stop"
            | "svg"
            | "switch"
            | "text"
            | "textPath"
            | "tspan"
            | "use"
            | "view"
            | (keyof HTMLElementTagNameMap)
            | (keyof MathMLElementTagNameMap)
            | (keyof TurboElementTagNameMap)

      Parameters

      • type: Type

        The (valid) CSS selector string, or element constructor/class to match.

      Returns ValidElement<Type>

      The matching ancestor element, or null if no match is found.

    • Type Parameters

      Parameters

      • type: new (...args: any[]) => Type

      Returns Type

    • Parameters

      • callback: (el: this) => void

        The function to execute, with 1 parameter representing the instance itself.

      Returns this

      Itself, allowing for method chaining.

      Execute a callback on the node while still benefiting from chaining.

    • Parameters

      • b: boolean

        Whether to show the element or not

      Returns this

      Itself, allowing for method chaining.

      Show or hide the element (based on CSS) by transitioning in/out of the element's showTransition.

    • Parameters

      • attribute: keyof CSSStyleDeclaration

        A string representing the style attribute to set.

      • value: string | number

        A string representing the value to set the attribute to.

      • Optionalinstant: boolean

        If true, will set the fields directly. Otherwise, will set them on next animation frame.

      Returns this

      Itself, allowing for method chaining.

      Set a certain style attribute of the element to the provided value.

    • Parameters

      • attribute: keyof CSSStyleDeclaration

        A string representing the style attribute to set.

      • value: string | number

        A string representing the value to set the attribute to.

      • Optionalseparator: string

        The separator to use between the existing and new value.

      • Optionalinstant: boolean

        If true, will set the fields directly. Otherwise, will set them on next animation frame.

      Returns this

      Itself, allowing for method chaining.

      Set a certain style attribute of the element to the provided value.

    • Parameters

      • styles: StylesType

        A CSS string of style attributes and their values, seperated by semicolons, or an object of CSS properties. Use the css literal function for autocompletion.

      • Optionalinstant: boolean

        If true, will set the fields directly. Otherwise, will set them on next animation frame.

      Returns this

      Itself, allowing for method chaining.

      Parses and applies the given CSS to the element's inline styles.

    • Returns string[]

    • Parameters

      • Optionalsubstrate: string

      Returns Set<object>

    • Parameters

      Returns this

    • Parameters

      • object: object
      • Optionalsubstrate: string

      Returns this

    • Parameters

      • object: object
      • Optionalsubstrate: string

      Returns this

    • Parameters

      • object: object
      • Optionalsubstrate: string

      Returns boolean

    • Parameters

      • object: object
      • Optionalsubstrate: string

      Returns boolean

    • Parameters

      • name: string

      Returns this

    • Parameters

      • Optionalname: string

      Returns Delegate<() => void>

    • Parameters

      • Optionalname: string

      Returns Delegate<() => void>

    • Parameters

      Returns this

    • Parameters

      Returns this

    • Parameters

      • Optionalname: string

      Returns this

    • Parameters

      • toolName: string

        The unique name of the tool to register under the manager.

      • Optionaloptions: MakeToolOptions

        Tool creation options (activation, click mode, key mapping, manager).

      Returns this

      Turns the element into a tool identified by toolName, optionally wiring activation and key mapping.

    • Parameters

      • Optionalmanager: TurboEventManager

        The associated event manager (defaults to TurboEventManager.instance).

      Returns boolean

      True if the element is a tool, false otherwise.

      Whether this element is registered as a tool for the provided manager.

    • Parameters

      • Optionalmanager: TurboEventManager

        The associated event manager (defaults to TurboEventManager.instance).

      Returns string[]

      The list of tool names.

      Returns all tool names registered on this element for the provided manager.

    • Parameters

      • Optionalmanager: TurboEventManager

        The associated event manager (defaults to TurboEventManager.instance).

      Returns string

      The first tool name, if any.

      Returns the first registered tool name on this element for the provided manager.

    • Parameters

      Returns Delegate<() => void>

      Delegate fired when this tool is activated (selected + activated by the manager).

    • Parameters

      Returns Delegate<() => void>

      Delegate fired when this tool is deactivated.

    • Parameters

      • type: string

        The behavior type/event name (e.g., "pointerdown", "click", custom turbo event).

      • callback: ToolBehaviorCallback

        The behavior function. Return true to consume.

      • OptionaltoolName: string

        Tool name to bind the behavior to. Defaults to this element's first tool.

      • Optionalmanager: TurboEventManager

        The manager under which the behavior is registered.

      Returns this

      Adds a behavior callback for a given tool and a given type. It is applied to all instances of the tool.

    • Parameters

      • type: string

        The behavior/event type to check.

      • OptionaltoolName: string

        The tool name to check under.

      • Optionalmanager: TurboEventManager

        The associated manager.

      Returns boolean

      True if one or more behaviors are registered.

      Checks whether there is at least one behavior for (type, toolName).

    • Parameters

      • type: string

        The behavior/event type to clear.

      • OptionaltoolName: string

        The tool name whose behaviors will be removed.

      • Optionalmanager: TurboEventManager

        The associated manager.

      Returns this

      Removes all behaviors for (type, toolName) under the given manager.

    • Parameters

      • toolName: string

        The tool whose behaviors should run.

      • type: string

        The behavior/event type to execute.

      • event: Event

        The triggering event instance.

      • Optionalmanager: TurboEventManager

        The associated manager.

      Returns boolean

      True if at least one behavior returned true (consumed).

      Executes all behaviors registered for (toolName, type) against this element.

    • Parameters

      • target: Node

        The node to manipulate when interacting with the element itself.

      • Optionalmanager: TurboEventManager

        The associated manager (defaults to TurboEventManager.instance).

      Returns this

      Embeds this tool into a target node, so interactions on the tool apply to the target.

    • Parameters

      • Optionalmanager: TurboEventManager

        The associated manager (defaults to TurboEventManager.instance).

      Returns boolean

      True if an embedded target is present.

      Whether this tool is embedded under the provided manager.

    • Parameters

      • Optionalmanager: TurboEventManager

        The associated manager (defaults to TurboEventManager.instance).

      Returns Node

      The embedded target node, if any.

      Returns the target node for this embedded tool under the provided manager.

    • Parameters

      • toolName: string
      • Optionaltype: string
      • Optionalignore: boolean
      • Optionalmanager: TurboEventManager

      Returns this

    • Parameters

      Returns boolean