Options
All
  • Public
  • Public/Protected
  • All
Menu

Class xjs_Node

Wrapper for a Node.

see

https://www.w3.org/TR/dom/#node

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

Properties

Private _NODE

_NODE: Node

The wrapped DOM Node.

Accessors

node

  • get node(): Node

Methods

empty

  • empty(): this

exe

  • exe(executable: function): this
  • deprecated

    DEPRECATED: Use .run() instead. Execute a function acting on this node, and then return this node.

    Simplifies chaining when performing void tasks, especially tasks that have not been defined in this implementation. Note that this function is not asynchronous, and does not accept asynchronous arguments.

    Parameters

    • executable: function

      the function to call in the context of this

        • (this: this): void
        • Parameters

          • this: this

          Returns void

    Returns this

    this

ifElse

  • ifElse(condition: any, onResolve: function, onReject?: function): this
  • deprecated

    DEPRECATED: Use .select() instead. Execute a function based on a condition.

    Given a condition, execute one function upon passing, or execute another upon failure. Note that this function is not asynchronous, and does not accept asynchronous arguments.

    Parameters

    • condition: any

      the condition to evaluate; will be converted to boolean

    • onResolve: function

      the executable to call (in the context of this) if the condition is truthy

        • (this: this): void
        • Parameters

          • this: this

          Returns void

    • Default value onReject: function = () => {}

      the executable to call (in the context of this) if the condition is falsy

        • (this: this): void
        • Parameters

          • this: this

          Returns void

    Returns this

    this

run

  • run(callback: function): this
  • Execute a callback acting on this node, and then return this node.

    Simplifies chaining when performing void tasks, especially tasks that have not been defined in this implementation. Note that this function is not asynchronous, and does not accept asynchronous arguments.

    Parameters

    • callback: function

      the function to call, taking this as its only argument, and returning void

        • (arg: this): void
        • Parameters

          • arg: this

          Returns void

    Returns this

    this

select

  • select(condition: unknown, onTrue: function, onFalse?: function): this
  • Execute a function based on a condition.

    Given a condition, execute one function upon passing, or execute another upon failure. Note that this function is not asynchronous, and does not accept asynchronous arguments.

    Parameters

    • condition: unknown

      the condition to evaluate; will be converted to boolean

    • onTrue: function

      the callback to call (with this as its parameter) if the condition is truthy

        • (arg: this): void
        • Parameters

          • arg: this

          Returns void

    • Default value onFalse: function = () => {}

      the callback to call (with this as its parameter) if the condition is falsy

        • (arg: this): void
        • Parameters

          • arg: this

          Returns void

    Returns this

    this

textContent

  • textContent(): string | null
  • textContent(text: string): this

trimInner

  • trimInner(): this
  • Remove all inner whitespace text nodes from this node, and return it.

    let div = document.createElement('div')
    div.innerHTML = `
      <h1>
        <em>Hello </em>
        <b>Worl d</b>
      </h1>
    `
    let trimmed_div = new xjs.Node(div).trimInner().node
    return div.innerHTML === `
      <h1>
        <em>Hello </em>
        <b>Worl d</b>
      </h1>
    `
      && trimmed_div.innerHTML = `<h1><em>Hello </em><b>Worl d</b></h1>`

    Returns this

    this

Generated using TypeDoc