Skip to content

Naming convention for on directive custom events #13185

Answered by brunnerh
S1r-Lanzelot asked this question in Q&A
Discussion options

You must be logged in to vote

The reason is that properties for these events really exist on elements, so adding an event that way is analogous to just setting those properties.

Event handlers are exposed in two ways.

The first way, common to all event handlers, is as an event handler IDL attribute.

The second way is as an event handler content attribute. Event handlers on HTML elements and some of the event handlers on Window objects are exposed in this way.

(See e.g. the interface for GlobalEventHandlers which are implemented by HTMLElement.)

Using properties instead of the special on: syntax allows event handlers to be spread in components like any other property. This is helpful for forwarding all events (see #2837

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by S1r-Lanzelot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants