Interface IsomorphicHTMLElement

Structure representing one HTML element

interface IsomorphicHTMLElement {
    attrs: Record<string, string>;
    nextSibling?: IsomorphicHTMLElement;
    previousSibling?: IsomorphicHTMLElement;
    text: string;
    extract<T>(selector, extraFilters?): undefined | T;
    extractAll<T>(selector, extraFilters?): T[];
    find(selector): undefined | IsomorphicHTMLElement;
    findAll(selector): IsomorphicHTMLElement[];
}

Properties

attrs: Record<string, string>

Get all element attributes

Param: selector

HTML selector

nextSibling?: IsomorphicHTMLElement

Get next sibling

previousSibling?: IsomorphicHTMLElement

Get previous sibling

text: string

Get the combined text contents of each element in the set of matched elements, including their descendants

Param: selector

HTML selector

Methods

  • Extract value from first found element by provided selector

    Type Parameters

    • T

    Parameters

    • selector: string

      HTML selector

    • Optional extraFilters: Record<string, Filter>

    Returns undefined | T

    Example

    el.extract('.content @ attrs.data-summary | trim | uppercase')

    el.extract('.content @ attrs.data-summary | myCallback | uppercase', {
    myCallback(value) {
    return typeof value === 'string' ? value.trim() : value
    }
    })

    Extra Filters

    custom filters

  • Extract value by provided selector

    Type Parameters

    • T

    Parameters

    • selector: string

      HTML selector

    • Optional extraFilters: Record<string, Filter>

    Returns T[]

    Example

    el.extractAll('.content @ attrs.data-summary | trim | uppercase')

    el.extractAll('.content @ attrs.data-summary | myCallback | uppercase', {
    myCallback(value) {
    return typeof value === 'string' ? value.trim() : value
    }
    })

    Extra Filters

    custom filters

Generated using TypeDoc