@thiagohp/tapestry-5
    Preparing search index...

    Interface ElementWrapper

    Wraps a DOM element, providing some common behaviors. Exposes the DOM element as property element.

    interface ElementWrapper {
        element: HTMLElement;
        addClass(name: string): ElementWrapper;
        append(content: AddableContent): ElementWrapper;
        attr(
            name: string | [key: string, value: string],
            value?: null | string | number | boolean,
        ): null | string | ElementWrapper;
        checked(): boolean;
        children(): ElementWrapper[];
        closest(selector: string): null | ElementWrapper;
        css(name: string, value: undefined | string): string | ElementWrapper;
        deepVisible(): boolean;
        find(selector: string): ElementWrapper[];
        findFirst(selector: string): null | ElementWrapper;
        findParent(selector: string): null | ElementWrapper;
        focus(): ElementWrapper;
        hasClass(name: string): boolean;
        hide(): ElementWrapper;
        insertAfter(content: AddableContent): ElementWrapper;
        insertBefore(content: AddableContent): ElementWrapper;
        meta(
            name: string,
            value?: null | string | boolean,
        ): null | string | boolean;
        offset(): ElementOffset;
        on(events: string, match: null | string, handler: OnEventHandler): any;
        parent(): null | ElementWrapper;
        prepend(content: AddableContent): ElementWrapper;
        remove(): ElementWrapper;
        removeClass(name: string): ElementWrapper;
        show(): ElementWrapper;
        text(): string;
        toString(): string;
        trigger(eventName: string, memo?: any): void;
        update(content: AddableContent): ElementWrapper;
        value(newValue?: null | string): null | String;
        visible(): boolean;
    }
    Index

    Properties

    element: HTMLElement

    Methods

    • Reads or updates an attribute. With one argument, returns the current value of the attribute. With two arguments, updates the attribute's value, and returns the previous value. Setting an attribute to null is the same as removing it.

      Alternately, the first attribute can be an object in which case all the keys and values of the object are applied as attributes, and this ElementWrapper is returned.

      Parameters

      • name: string | [key: string, value: string]

        the attribute to read or update, or an object of keys and values

      • Optionalvalue: null | string | number | boolean

        (optional) the new value for the attribute

      Returns null | string | ElementWrapper

    • Returns true if element is a checkbox and is checked.

      Returns boolean

      true of false

    • Returns this ElementWrapper if it matches the selector; otherwise, returns the first container element (as an ElementWrapper) that matches the selector. Returns null if no container element matches.

      Parameters

      • selector: string

        a CSS selector

      Returns null | ElementWrapper

      an element wrapper or null.

    • Gets or sets a CSS property.

      Parameters

      • name: string

        name the name of the property.

      • value: undefined | string

        the value of the property.

      Returns string | ElementWrapper

      this.

    • Returns true if this element is visible, and all parent elements are also visible, up to the document body.

      Returns boolean

      true or false

    • Finds all child elements matching the CSS selector, returning them as an array of ElementWrappers.

      Parameters

      • selector: string

        a CSS selector.

      Returns ElementWrapper[]

      the matching child elements as an array of ElementWrapper instances

    • Finds the first child element that matches the CSS selector, wrapped as an ElementWrapper. Returns null if not found.

      Parameters

      • selector: string

        a CSS selector

      Returns null | ElementWrapper

    • Finds the first container element that matches the CSS selector, wrapped as an ElementWrapper. Returns null if not found.

      Parameters

      • selector: string

        a CSS selector

      Returns null | ElementWrapper

      an element wrapper or null. *

    • Returns true if the element has the indicated class name, false otherwise.

      Parameters

      • name: string

        the class name

      Returns boolean

      true of false

    • Stores or retrieves meta-data on the element. With one parameter, the current value for the name is returned (or undefined). With two parameters, the meta-data is updated and the previous value returned. For Prototype, the meta data is essentially empty (except, perhaps, for some internal keys used to store event handling information). For jQuery, the meta data may be initialized from data- attributes.

      Parameters

      • name: string

        name of meta-data value to store or retrieve

      • Optionalvalue: null | string | boolean

        (optional) new value for meta-data

      Returns null | string | boolean

    • Adds an event handler for one or more events.

      Parameters

      • events: string

        one or more event names, separated by spaces

      • match: null | string

        optional: CSS expression used as a filter; only events that bubble up to the wrapped element from an originating element that matches the CSS expression will invoke the handler.

      • handler: OnEventHandler

        function invoked; the function is passed an EventWrapper object, and the context (this) is the ElementWrapper for the matched element.

      Returns any

    • Returns an ElementWrapper for this element's containing element. Returns null if this element has no parent (either because this element is the document object, or because this element is not yet attached to the DOM).

      Returns null | ElementWrapper

      an element wrapper or null.

    • Returns the text of the element and its children.

      Returns string

      the element's text.

    • Fires a named event, passing an optional memo object to event handler functions. This must support common native events (exact list TBD), as well as custom events (in Prototype, custom events must have a prefix that ends with a colon).

      Parameters

      • eventName: string

        name of event to trigger on the wrapped Element

      • Optionalmemo: any

        optional value assocated with the event; available as WrappedeEvent.memo in event handler functions (must be null for native events). The memo, when provided, should be an object; it is an error if it is a string or other non-object type..

      Returns void

      true if the event fully executed, or false if the event was canceled.

    • With no parameters, returns the current value of the element (which must be a form control element, such as <input> or <textarea>). With one parameter, updates the field's value, and returns the previous value. The underlying foundation is responsible for mapping this correctly based on the type of control element. TODO: Define behavior for multi-named elements, such as <select>.

      Parameters

      • OptionalnewValue: null | string

        (optional) new value for field

      Returns null | String

    • Returns true if this element is visible, false otherwise. This does not check to see if all containers of the element are visible.

      Returns boolean

      true or false