@miaskiewicz/turbo-dom 0.1.41 → 0.1.42

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miaskiewicz/turbo-dom",
3
- "version": "0.1.41",
3
+ "version": "0.1.42",
4
4
  "description": "Faster, more spec-correct DOM for test runners — native html5ever (Rust/WASM) parser + lazy copy-on-write DOM. A drop-in-style alternative to jsdom/happy-dom for vitest & jest.",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -238,8 +238,13 @@ export class EventTarget {
238
238
  event.target = retarget(target, node);
239
239
  if (relatedTarget != null) event.relatedTarget = retarget(relatedTarget, node);
240
240
  }
241
- // snapshot — listeners added during dispatch don't fire this round
242
- for (const l of list.slice()) {
241
+ // snapshot — listeners added during dispatch don't fire this round. Skip the
242
+ // slice alloc for the single-listener case (common React-delegated one): a
243
+ // 1-element, length-captured iteration can't be disturbed by an add/remove in
244
+ // that one call. Multi-listener keeps the slice (concurrent-mutation guard).
245
+ const snap = list.length === 1 ? list : list.slice();
246
+ for (let k = 0, len = snap.length; k < len; k++) {
247
+ const l = snap[k];
243
248
  if (phase === PHASE_CAPTURING && !l.capture) continue;
244
249
  if (phase === PHASE_BUBBLING && l.capture) continue;
245
250
  if (l.once) {