hubcap listeners — List event listeners on an element

When to use

List event listeners attached to an element. Useful for debugging event handling and understanding which events an element responds to.

Usage

hubcap listeners <selector>

Arguments

ArgumentTypeRequiredDescription
selectorstringyesCSS selector of the element to inspect

Flags

None.

Output

Returns an object containing an array of event listener objects.

FieldTypeDescription
listenersarrayArray of event listener objects
listeners[].typestringThe event type (e.g., “click”, “input”)
listeners[].useCapturebooleanWhether the listener uses capture phase
listeners[].passivebooleanWhether the listener is passive
listeners[].oncebooleanWhether the listener fires only once
listeners[].scriptIdstringScript identifier where the listener is defined
listeners[].lineNumbernumberLine number in the script
listeners[].columnNumbernumberColumn number in the script
{
  "listeners": [
    {"type":"click","useCapture":false,"passive":false,"once":false,"scriptId":"32","lineNumber":10,"columnNumber":2},
    {"type":"input","useCapture":false,"passive":true,"once":false,"scriptId":"32","lineNumber":15,"columnNumber":2}
  ]
}

Errors

ConditionExit codeStderr
Element not found1error: element not found: <sel>
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

List all event listeners on a button:

hubcap listeners '#submit'

List listeners and filter to just click handlers:

hubcap listeners '#submit' | jq '[.listeners[] | select(.type == "click")]'

See also

  • dispatch - Dispatch an event on an element
  • query - Query a DOM element
  • styles - Get computed CSS styles