Function matchListener

  • Takes advantage of event bubbling to listen for events on descendant elements to reduce the number of listeners to create.

    Parameters

    • matcher: IMatcher

      Map of event target matcher to associated handler function

    • Optional wrapListeners: boolean

      Whether to werap the matcher functions with eventListener.

    Returns ((e) => any)

    Example

    import { matchListener } from 'deleight/eutility';
    window.mainTable.onclick = matchListener({
    'a.lbl': e => select(e.target.parentNode.parentNode),
    'span.remove': [removeListener, preventDefault, stopPropagation]
    }, true);