Interface defining the parameters to be passed to the LabIcon constructor

interface IOptions {
    name: string;
    render?: ((host, options?) => void);
    svgstr: string;
    unrender?: ((host, options?) => void);
}

Hierarchy (view full)

Properties

name: string

The name of the icon. By convention, the icon name will be namespaced as so:

"pkg-name:icon-name"
render?: ((host, options?) => void)

Customize how a DOM node is rendered. If .renderer is set on a given instance of VirtualElement, this function will be called every time that VirtualElement is rendered.

Type declaration

    • (host, options?): void
    • Parameters

      • host: HTMLElement

        The actual DOM node created for a VirtualElement during rendering.

        On render, host is created and its attrs are set/updated via the standard routines in updateContent. host is then handed off to this function.

        The render function is free to modify host. The only restriction is is that render should not modify any attributes set by external routines (ie updateContent), as this may cause thrashing when the virtual element is next rendered.

      • Optional options: {
            attrs?: ElementAttrs;
            children?: readonly VirtualNode[];
        }

        Will be populated with the .attrs and .children fields set on the VirtualElement being rendered.

        • Optional attrs?: ElementAttrs
        • Optional children?: readonly VirtualNode[]

      Returns void

svgstr: string

A string containing the raw contents of an svg file.

unrender?: ((host, options?) => void)

Optional cleanup function for custom renderers. If the .renderer field of a VirtualELement is set, and if .renderer.unrender is defined, when the element is changed or removed its corresponding DOM element will be passed to this function immediately before it is removed from the DOM.

unrender is not required for for simple renderers, such as those implemented using document.createElement(). However, for certain rendering techniques explicit cleanup is required in order to avoid resource leaks.

For example, if render calls ReactDOM.render(..., host), then there has to also be a corresponding implementation of unrender that calls ReactDOM.unmountComponentAtNode(host) in order to prevent a memory leak.

Type declaration

    • (host, options?): void
    • Parameters

      • host: HTMLElement

        the DOM element to be removed.

      • Optional options: {
            attrs?: ElementAttrs;
            children?: readonly VirtualNode[];
        }

        Will be populated with the .attrs and .children fields set on the VirtualElement being unrendered.

        • Optional attrs?: ElementAttrs
        • Optional children?: readonly VirtualNode[]

      Returns void