A static class that provides helper methods to generate clickable nodes that execute registered commands with pre-populated arguments.

Implements

Constructors

Properties

_commands: CommandRegistry
_isDisposed: boolean = false

Accessors

Methods

  • Connect a command/argument pair to a given node so that when it is clicked, the command will execute.

    Parameters

    • node: HTMLElement

      The node being connected.

    • command: string

      The command ID to execute upon click.

    • Optional args: ReadonlyPartialJSONObject

      The arguments with which to invoke the command.

    Returns HTMLElement

    The same node that was passed in, after it has been connected.

    Notes

    Only click events will execute the command on a connected node. So, there are two considerations that are relevant:

    1. If a node is connected, the default click action will be prevented.
    2. The HTMLElement passed in should be clickable.
  • Disconnect a node that has been connected to execute a command on click.

    Parameters

    Returns HTMLElement

    The same node that was passed in, after it has been disconnected.

    Notes

    This method is safe to call multiple times and is safe to call on nodes that were never connected.

    This method can be called on rendered virtual DOM nodes that were populated using the populateVNodeDataset method in order to disconnect them from executing their command/argument pair.

  • Handle the DOM events for the command linker helper class.

    Parameters

    • event: Event

      The DOM event sent to the class.

      Notes

      This method implements the DOM EventListener interface and is called in response to events on the panel's DOM node. It should not be called directly by user code.

    Returns void

  • Populate the dataset attribute within the collection of attributes used to instantiate a virtual DOM node with the values necessary for its rendered DOM node to respond to clicks by executing a command/argument pair.

    Parameters

    • command: string

      The command ID to execute upon click.

    • Optional args: ReadonlyPartialJSONObject

      The arguments with which to invoke the command.

    Returns ElementDataset

    A dataset collection for use within virtual node attributes.

    Notes

    The return value can be used on its own as the value for the dataset attribute of a virtual element, or it can be added to an existing dataset as in the example below.

    Example

    let command = 'some:command-id';
    let args = { alpha: 'beta' };
    let anchor = h.a({
    className: 'some-class',
    dataset: {
    foo: '1',
    bar: '2',
    ../...linker.populateVNodeDataset(command, args)
    }
    }, 'some text');