SolidJSS
SolidJSโ€ข11mo agoโ€ข
10 replies
JonathanExcelsior

How does Solid attach event handlers to DOM elements?

I want to test wether a DOM element has an onclick event handler. However, using the onclick (delgated event) in the JSX component, there is a $$click property added to the DOM element with the event handler and the onclick property is null. Using on:click (native element) on the JSX component, there is no $$click property and onclick is still null. What is the underlying mechanism for adding an event handler to DOM elements?

ref: https://docs.solidjs.com/concepts/components/event-handlers

Also, as a follow up, how would I test that an event handler is present on a DOM element? I'm currently using Vitest and Testing Library.

Thanks in advance.
Was this page helpful?