You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .changeset/shaky-pianos-wait.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,4 +2,5 @@
2
2
'@qwik.dev/core': major
3
3
---
4
4
5
-
BREAKING: (slightly) custom event handlers no longer use a `-` prefix to denote case sensitive events. Instead, write the event name in kebab-case directly. For example, the custom event `CustomEvent` should now be written as `on-Custom-Event$` instead of `on-CustomEvent$`. The handler will be called for events named `CustomEvent` but also for `-custom-event`, which should not be a problem in practice.
5
+
BREAKING: (slightly) `-` handling in JSX event handlers has slightly changed. Now, if an event name starts with `-`, the rest of the name will be kept as-is, preserving casing. Otherwise, the event name is made lowercase. Any `-` characters in the middle of the name are preserved as-is. Previously, `-` were considered to mark the next letter as uppercase.
6
+
For example, `onCustomEvent$` will match `customevent`, `on-CustomEvent$` will match `CustomEvent`, and `onCustom-Event$` will match `custom-event`. Before, that last one would match `customEvent` instead.
Event names are case sensitive, but all DOM events except for `DOMContentLoaded` are lowercase. For a better DX, event names are always lowercased, so `onTripleClick$` becomes `tripleclick` under the hood.
304
304
305
-
To listen for a custom event with uppercase letters, you must use kebab-case. For example, to listen for a custom event named `CustomEvent`, you would use `on-Custom-Event$` or `on-custom-event$`. The handler would then be called for events named: `CustomEvent`, `-custom-event`, `Custom-event` and `-customEvent`. In practice, this combining of events should not be a problem, but you can check the exact event name in the handler if needed.
305
+
To listen for a custom event with uppercase letters, you add a `-` after `on`. For example, to listen for a custom event named `CustomEvent`, you would use `on-CustomEvent$`. For a window event named`Hi-There`, you would use `window:on-Hi-There$`.
Copy file name to clipboardExpand all lines: packages/qwik/src/core/readme.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -160,7 +160,7 @@ Register a listener on the current component's host element.
160
160
161
161
Used to programmatically add event listeners. Useful from custom `use*` methods, which do not have access to the JSX. Otherwise, it's adding a JSX listener in the `<div>` is a better idea.
162
162
163
-
Event names are converted to lowercase (except for `DOMContentLoaded`). If you need to listen to a case-sensitive custom event, use kebab-case. For example, to listen to `CustomEvent`, use `-Custom-Event` or `-custom-event`. This will listen for `CustomEvent`, but also for `-custom-event`, `Custom-event` and `-customEvent`. In practice, this should not be a problem. You can always check the exact event name in the handler if needed.
163
+
Events are case sensitive.
164
164
165
165
@see`useOn`, `useOnWindow`, `useOnDocument`.
166
166
@@ -172,7 +172,7 @@ Register a listener on `window`.
172
172
173
173
Used to programmatically add event listeners. Useful from custom `use*` methods, which do not have access to the JSX.
174
174
175
-
Event names are converted to lowercase (except for `DOMContentLoaded`). If you need to listen to a case-sensitive custom event, use kebab-case. For example, to listen to `CustomEvent`, use `-Custom-Event` or `-custom-event`. This will listen for `CustomEvent`, but also for `-custom-event`, `Custom-event` and `-customEvent`. In practice, this should not be a problem. You can always check the exact event name in the handler if needed.
175
+
Events are case sensitive.
176
176
177
177
@see`useOn`, `useOnWindow`, `useOnDocument`.
178
178
@@ -186,7 +186,7 @@ Register a listener on `document`.
186
186
187
187
Used to programmatically add event listeners. Useful from custom `use*` methods, which do not have access to the JSX.
188
188
189
-
Event names are converted to lowercase (except for `DOMContentLoaded`). If you need to listen to a case-sensitive custom event, use kebab-case. For example, to listen to `CustomEvent`, use `-Custom-Event` or `-custom-event`. This will listen for `CustomEvent`, but also for `-custom-event`, `Custom-event` and `-customEvent`. In practice, this should not be a problem. You can always check the exact event name in the handler if needed.
0 commit comments