@juspay/svelte-ui-components 4.10.1 → 4.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +27 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -243,6 +243,33 @@ import '@juspay/svelte-ui-components/wc';
243
243
  Theming works identically to the Svelte components — the same `--{component}-{element}-{property}`
244
244
  CSS custom properties apply across the shadow DOM boundary.
245
245
 
246
+ ### Event handlers: use `addEventListener`, not `element.onclick`
247
+
248
+ Handlers are passed as **props**, and 91 of those props are named after event-handler
249
+ accessors that already exist on `HTMLElement` — `onclick`, `onchange`, `oninput`,
250
+ `onkeydown` and 21 others. On a custom element the component's prop wins, so assigning
251
+ the property does not register a DOM handler the way it would anywhere else:
252
+
253
+ ```js
254
+ const checkbox = document.querySelector('sui-checkbox');
255
+
256
+ // Sets the component's prop. On sui-checkbox and sui-toggle that prop is called
257
+ // with a boolean, so `event` here is `true` / `false`, not a MouseEvent.
258
+ checkbox.onclick = (event) => console.log(event.clientX); // undefined
259
+
260
+ // Always does what you expect.
261
+ checkbox.addEventListener('click', (event) => console.log(event.clientX));
262
+ ```
263
+
264
+ Two things are **not** affected: the inline HTML attribute (`<sui-button onclick="...">`)
265
+ never used this accessor, and `addEventListener` is untouched. Only the JavaScript
266
+ property assignment differs.
267
+
268
+ Renaming these is a breaking change to every element's JavaScript API, so the whole set
269
+ has to move at once at a major — the same way the `aria*` collisions were renamed in
270
+ 4.0.0. Until then the existing declarations are recorded in
271
+ `scripts/wc-parity/prop-parity.test.ts`, which fails the build on a new one.
272
+
246
273
  ---
247
274
 
248
275
  ## Theming
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/svelte-ui-components",
3
- "version": "4.10.1",
3
+ "version": "4.10.2",
4
4
  "description": "A themeable Svelte 5 UI component library with CSS custom property driven styling",
5
5
  "keywords": [
6
6
  "svelte",