@skirbi/sugar 0.1.15 → 0.1.16

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.
package/Changes CHANGED
@@ -1,5 +1,12 @@
1
1
  Revision history for @skirbi/sugar
2
2
 
3
+ 0.1.16 2026-07-08 15:47:05Z
4
+
5
+ * Fix event handling in testsuites. Under jsdom, a bare `Event` reference
6
+ resolves to Node's own global Event class, not a jsdom window.Event.
7
+ Jsdom's dispatchEvent rejects an event instance that isn't its own realm's
8
+ Event, so window.Event must be preferred whenever it exists.
9
+
3
10
  0.1.15 2026-07-03 22:08:57Z
4
11
 
5
12
  * Add MouseEvent for @skirbi/semtic
@@ -185,6 +185,10 @@ export class HTMLElementSugarInput extends HTMLElementSugar {
185
185
  setupFormControl(control) {
186
186
  const valueAttr = this.constructor.valueAttr || 'value';
187
187
 
188
+ // Resolve Event from the current runtime (jsdom exposes it on window, not
189
+ // always on globalThis)
190
+ const EventCtor = globalThis.window?.Event || globalThis.Event;
191
+
188
192
  const syncHostValue = () => {
189
193
  if ('value' in control) {
190
194
  this.setAttribute(valueAttr, control.value ?? '');
@@ -193,12 +197,12 @@ export class HTMLElementSugarInput extends HTMLElementSugar {
193
197
 
194
198
  control.addEventListener('input', () => {
195
199
  syncHostValue();
196
- this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
200
+ this.dispatchEvent(new EventCtor('input', { bubbles: true, composed: true }));
197
201
  });
198
202
 
199
203
  control.addEventListener('change', () => {
200
204
  syncHostValue();
201
- this.dispatchEvent(new Event('change', { bubbles: true,
205
+ this.dispatchEvent(new EventCtor('change', { bubbles: true,
202
206
  composed: true }));
203
207
  });
204
208
  }
package/lib/index.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  //
3
3
  // SPDX-License-Identifier: MIT
4
4
 
5
- const VERSION = "0.1.15";
5
+ const VERSION = "0.1.16";
6
6
 
7
7
  export { HTMLElementSugar } from './htmlelement.mjs';
8
8
  export { HTMLElementSugarInput } from './htmlelement-input.mjs';
package/package.json CHANGED
@@ -62,5 +62,5 @@
62
62
  "./aliases-register"
63
63
  ],
64
64
  "type": "module",
65
- "version": "0.1.15"
65
+ "version": "0.1.16"
66
66
  }