thunderous 2.3.3 → 2.3.5

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/dist/index.cjs CHANGED
@@ -87,11 +87,15 @@ var createSignal = (initVal, options) => {
87
87
  if (!isBatchingUpdates) {
88
88
  isBatchingUpdates = true;
89
89
  queueMicrotask(() => {
90
- for (const fn of updateQueue) {
91
- try {
92
- fn();
93
- } catch (error) {
94
- console.error("Error in subscriber:", { error, oldValue, newValue, fn });
90
+ while (updateQueue.size > 0) {
91
+ const updates = Array.from(updateQueue);
92
+ updateQueue.clear();
93
+ for (const fn of updates) {
94
+ try {
95
+ fn();
96
+ } catch (error) {
97
+ console.error("Error in subscriber:", { error, oldValue, newValue, fn });
98
+ }
95
99
  }
96
100
  }
97
101
  if (options?.debugMode === true || setterOptions?.debugMode === true) {
@@ -106,7 +110,6 @@ var createSignal = (initVal, options) => {
106
110
  }
107
111
  console.log("Signal set:", { oldValue, newValue, subscribers, label });
108
112
  }
109
- updateQueue.clear();
110
113
  isBatchingUpdates = false;
111
114
  });
112
115
  }
@@ -448,6 +451,8 @@ var evaluateBindings = (element, fragment) => {
448
451
  child.replaceWith(childFragment);
449
452
  }
450
453
  } else if (child instanceof Element) {
454
+ const attrRemoveQueue = [];
455
+ const attrSetQueue = [];
451
456
  for (const attr of child.attributes) {
452
457
  const attrName = attr.name;
453
458
  if (SIGNAL_BINDING_REGEX.test(attr.value)) {
@@ -458,21 +463,25 @@ var evaluateBindings = (element, fragment) => {
458
463
  let signal;
459
464
  for (const text of textList) {
460
465
  const uniqueKey = text.replace(/\{\{signal:(.+)\}\}/, "$1");
461
- signal = uniqueKey !== text ? renderState.signalMap.get(uniqueKey) : void 0;
462
- const value = signal !== void 0 ? signal() : text;
463
- if (value === null) hasNull = true;
464
- newText += String(value);
466
+ if (signal === void 0) {
467
+ signal = uniqueKey !== text ? renderState.signalMap.get(uniqueKey) : void 0;
468
+ const value = signal !== void 0 ? signal() : text;
469
+ if (value === null) hasNull = true;
470
+ newText += String(value);
471
+ } else {
472
+ newText += text;
473
+ }
465
474
  }
466
475
  if (hasNull && newText === "null" || attrName.startsWith("prop:")) {
467
- child.removeAttribute(attrName);
476
+ attrRemoveQueue.push(attrName);
468
477
  } else {
469
- child.setAttribute(attrName, newText);
478
+ attrSetQueue.push([attrName, newText]);
470
479
  }
471
480
  if (attrName.startsWith("prop:")) {
472
- child.removeAttribute(attrName);
481
+ attrRemoveQueue.push(attrName);
473
482
  const propName = attrName.replace("prop:", "");
474
- if (!(propName in child)) logPropertyWarning(propName, child);
475
483
  const newValue = hasNull && newText === "null" ? null : newText;
484
+ if (!(propName in child)) logPropertyWarning(propName, child);
476
485
  child[propName] = signal !== void 0 ? signal() : newValue;
477
486
  }
478
487
  });
@@ -496,21 +505,27 @@ var evaluateBindings = (element, fragment) => {
496
505
  }
497
506
  }
498
507
  if (uniqueKey !== "" && !attrName.startsWith("prop:")) {
499
- child.setAttribute(attrName, `this.__customCallbackFns.get('${uniqueKey}')(event)`);
508
+ attrSetQueue.push([attrName, `this.__customCallbackFns.get('${uniqueKey}')(event)`]);
500
509
  } else if (attrName.startsWith("prop:")) {
501
- child.removeAttribute(attrName);
510
+ attrRemoveQueue.push(attrName);
502
511
  const propName = attrName.replace("prop:", "");
503
512
  if (!(propName in child)) logPropertyWarning(propName, child);
504
513
  child[propName] = child.__customCallbackFns.get(uniqueKey);
505
514
  }
506
515
  });
507
516
  } else if (attrName.startsWith("prop:")) {
508
- child.removeAttribute(attrName);
517
+ attrRemoveQueue.push(attrName);
509
518
  const propName = attrName.replace("prop:", "");
510
519
  if (!(propName in child)) logPropertyWarning(propName, child);
511
520
  child[propName] = attr.value;
512
521
  }
513
522
  }
523
+ for (const attrName of attrRemoveQueue) {
524
+ child.removeAttribute(attrName);
525
+ }
526
+ for (const [name, value] of attrSetQueue) {
527
+ child.setAttribute(name, value);
528
+ }
514
529
  evaluateBindings(child, fragment);
515
530
  }
516
531
  }
package/dist/index.js CHANGED
@@ -52,11 +52,15 @@ var createSignal = (initVal, options) => {
52
52
  if (!isBatchingUpdates) {
53
53
  isBatchingUpdates = true;
54
54
  queueMicrotask(() => {
55
- for (const fn of updateQueue) {
56
- try {
57
- fn();
58
- } catch (error) {
59
- console.error("Error in subscriber:", { error, oldValue, newValue, fn });
55
+ while (updateQueue.size > 0) {
56
+ const updates = Array.from(updateQueue);
57
+ updateQueue.clear();
58
+ for (const fn of updates) {
59
+ try {
60
+ fn();
61
+ } catch (error) {
62
+ console.error("Error in subscriber:", { error, oldValue, newValue, fn });
63
+ }
60
64
  }
61
65
  }
62
66
  if (options?.debugMode === true || setterOptions?.debugMode === true) {
@@ -71,7 +75,6 @@ var createSignal = (initVal, options) => {
71
75
  }
72
76
  console.log("Signal set:", { oldValue, newValue, subscribers, label });
73
77
  }
74
- updateQueue.clear();
75
78
  isBatchingUpdates = false;
76
79
  });
77
80
  }
@@ -413,6 +416,8 @@ var evaluateBindings = (element, fragment) => {
413
416
  child.replaceWith(childFragment);
414
417
  }
415
418
  } else if (child instanceof Element) {
419
+ const attrRemoveQueue = [];
420
+ const attrSetQueue = [];
416
421
  for (const attr of child.attributes) {
417
422
  const attrName = attr.name;
418
423
  if (SIGNAL_BINDING_REGEX.test(attr.value)) {
@@ -423,21 +428,25 @@ var evaluateBindings = (element, fragment) => {
423
428
  let signal;
424
429
  for (const text of textList) {
425
430
  const uniqueKey = text.replace(/\{\{signal:(.+)\}\}/, "$1");
426
- signal = uniqueKey !== text ? renderState.signalMap.get(uniqueKey) : void 0;
427
- const value = signal !== void 0 ? signal() : text;
428
- if (value === null) hasNull = true;
429
- newText += String(value);
431
+ if (signal === void 0) {
432
+ signal = uniqueKey !== text ? renderState.signalMap.get(uniqueKey) : void 0;
433
+ const value = signal !== void 0 ? signal() : text;
434
+ if (value === null) hasNull = true;
435
+ newText += String(value);
436
+ } else {
437
+ newText += text;
438
+ }
430
439
  }
431
440
  if (hasNull && newText === "null" || attrName.startsWith("prop:")) {
432
- child.removeAttribute(attrName);
441
+ attrRemoveQueue.push(attrName);
433
442
  } else {
434
- child.setAttribute(attrName, newText);
443
+ attrSetQueue.push([attrName, newText]);
435
444
  }
436
445
  if (attrName.startsWith("prop:")) {
437
- child.removeAttribute(attrName);
446
+ attrRemoveQueue.push(attrName);
438
447
  const propName = attrName.replace("prop:", "");
439
- if (!(propName in child)) logPropertyWarning(propName, child);
440
448
  const newValue = hasNull && newText === "null" ? null : newText;
449
+ if (!(propName in child)) logPropertyWarning(propName, child);
441
450
  child[propName] = signal !== void 0 ? signal() : newValue;
442
451
  }
443
452
  });
@@ -461,21 +470,27 @@ var evaluateBindings = (element, fragment) => {
461
470
  }
462
471
  }
463
472
  if (uniqueKey !== "" && !attrName.startsWith("prop:")) {
464
- child.setAttribute(attrName, `this.__customCallbackFns.get('${uniqueKey}')(event)`);
473
+ attrSetQueue.push([attrName, `this.__customCallbackFns.get('${uniqueKey}')(event)`]);
465
474
  } else if (attrName.startsWith("prop:")) {
466
- child.removeAttribute(attrName);
475
+ attrRemoveQueue.push(attrName);
467
476
  const propName = attrName.replace("prop:", "");
468
477
  if (!(propName in child)) logPropertyWarning(propName, child);
469
478
  child[propName] = child.__customCallbackFns.get(uniqueKey);
470
479
  }
471
480
  });
472
481
  } else if (attrName.startsWith("prop:")) {
473
- child.removeAttribute(attrName);
482
+ attrRemoveQueue.push(attrName);
474
483
  const propName = attrName.replace("prop:", "");
475
484
  if (!(propName in child)) logPropertyWarning(propName, child);
476
485
  child[propName] = attr.value;
477
486
  }
478
487
  }
488
+ for (const attrName of attrRemoveQueue) {
489
+ child.removeAttribute(attrName);
490
+ }
491
+ for (const [name, value] of attrSetQueue) {
492
+ child.setAttribute(name, value);
493
+ }
479
494
  evaluateBindings(child, fragment);
480
495
  }
481
496
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thunderous",
3
- "version": "2.3.3",
3
+ "version": "2.3.5",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",