Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event names should be kebab-case naming convention #214

Open
pomczys opened this issue Jan 6, 2025 · 2 comments
Open

Event names should be kebab-case naming convention #214

pomczys opened this issue Jan 6, 2025 · 2 comments

Comments

@pomczys
Copy link

pomczys commented Jan 6, 2025

In core.ts event name is determined by code:
const name = event.replace(/^on/, "").toLowerCase()
so if I have a property called onComponentReady the event name will be componentready, but should be component-ready

@bmomberger-bitovi
Copy link
Contributor

This is done to match how event names are handled in the DOM. With the exception of certain events prefixed with "DOM" and otherwise camel cased, all event names and their "on" property equivalents are lowercased such as "readystatechange" / "onreadystatechange"

https://en.wikipedia.org/wiki/DOM_event

It's important to distinguish the convention here, that events are by convention lowercased, whereas attributes of an HTML element are kebab cased. When using the events feature in r2wc, it is not necessary to provide attribute values to receive events from "onX" functions.

@pomczys
Copy link
Author

pomczys commented Jan 7, 2025

Build in DOM events are named lower case unhyphenated.
But for custom events I prefer kebab-case naming convencion
Kebab-case is also recommended by Vue: https://eslint.vuejs.org/rules/custom-event-name-casing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants