Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "utils/helpers"

Index

Type aliases

NodeIterator

NodeIterator: (node: NodeImpl) => NodeImpl | null

A predicate used while iterating DOM tree. See lookupThrough for more detail.

Type declaration

    • (node: NodeImpl): NodeImpl | null
    • Parameters

      • node: NodeImpl

      Returns NodeImpl | null

NodeMatcher

NodeMatcher: (node: NodeImpl, ...args: any[]) => any | null | undefined

A predicate used while iterating DOM tree. Whose return value affects the flow of iteration.

Type declaration

    • (node: NodeImpl, ...args: any[]): any | null | undefined
    • Parameters

      • node: NodeImpl
      • Rest ...args: any[]

      Returns any | null | undefined

Functions

childElementCount

  • childElementCount(node: NodeImpl, ignoreWhiteSpace?: boolean): number
  • Counts all immediate element children

    Parameters

    • node: NodeImpl
    • Default value ignoreWhiteSpace: boolean = true

    Returns number

descend

  • descend(node: NodeImpl, match: NodeMatcher, ...args: any[]): NodeImpl | null
  • Descend the given node (excluding itself) breadth-first. Child nodes of the current node are pushed to stack before calling the match predicate. If match() returns true, the loop will break, returning the node at that point.

    Parameters

    • node: NodeImpl
    • match: NodeMatcher
    • Rest ...args: any[]

    Returns NodeImpl | null

firstCDataChild

  • firstCDataChild(node: NodeImpl): CommentImpl | null
  • Retrieves the first CData child of the given node.

    Parameters

    • node: NodeImpl

    Returns CommentImpl | null

firstCommentChild

  • firstCommentChild(node: NodeImpl): CommentImpl | null
  • Retrieves the first comment child of the given node.

    Parameters

    • node: NodeImpl

    Returns CommentImpl | null

firstElementChild

  • firstElementChild(node: NodeImpl): ElementImpl | null
  • Retrieves the first element child of the given node.

    Parameters

    • node: NodeImpl

    Returns ElementImpl | null

firstProcessingInstructionChild

  • firstProcessingInstructionChild(node: NodeImpl): ProcessingInstructionImpl | null
  • Retrieves the first processing instruction child of the given node.

    Parameters

    • node: NodeImpl

    Returns ProcessingInstructionImpl | null

isEmptyText

  • isEmptyText(node: NodeImpl): boolean
  • Check if the given node is a white space text node

    Parameters

    • node: NodeImpl

    Returns boolean

lookupAncestor

  • lookupAncestor(node: NodeImpl, match: NodeMatcher, ...args: any[]): any | null
  • Looks up for something matching certain criteria, falling back to ancestors all the way to the document root. Starting from the given node.

    The match callback should determine whether a given node fulfills criteria. If match() returns a value that is not null or undefined, the loop will return immediately, with the return value from match().

    Parameters

    • node: NodeImpl

      The node to start looking.

    • match: NodeMatcher

      A callback function to determine if the node matches criteria.

    • Rest ...args: any[]

      Extra arguments to be passed to match callback.

    Returns any | null

lookupSibling

  • lookupSibling(node: NodeImpl, match: NodeMatcher, ...args: any[]): any | null
  • Looks up for something matching certain criteria, among siblings from node onward.

    The match callback should determine whether a given node fulfills criteria. If match() returns a value that is not null or undefined, the loop will return immediately, with the return value from match().

    Parameters

    • node: NodeImpl

      The node to start looking.

    • match: NodeMatcher

      A callback function to determine if the node matches criteria.

    • Rest ...args: any[]

      Extra arguments to be passed to match callback.

    Returns any | null

lookupThrough

  • Looks up for something matching certain criteria.

    The next callback should return the next node of interest. If next() returns a falsy value, the loop breaks and returns null.

    The match callback should determine whether a given node fulfills criteria. If match() returns a value that is not null or undefined, the loop will return immediately, with the return value from match().

    Parameters

    • node: NodeImpl | null

      The node to start looking.

    • match: NodeMatcher

      A callback function to determine if the node matches criteria.

    • next: NodeIterator

      A callback that returns the next node to be matched.

    • Rest ...args: any[]

      Extra arguments to be passed to match callback.

    Returns any | null

nextElementSibling

  • nextElementSibling(node: NodeImpl): ElementImpl | null
  • Retrieves the next element sibling of the given node.

    Parameters

    • node: NodeImpl

    Returns ElementImpl | null

removeEmptyTextNodes

  • removeEmptyTextNodes(node: NodeImpl): void
  • Remove all empty text nodes from descendants of the given node.

    Parameters

    • node: NodeImpl

    Returns void

trimTextContents

  • trimTextContents(node: NodeImpl): void
  • {@link String.trim} all descendants' text nodes.

    Parameters

    • node: NodeImpl

    Returns void

Generated using TypeDoc