thunderous 2.0.2 → 2.0.4
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 +25 -1
- package/dist/index.js +25 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -377,6 +377,7 @@ var evaluateBindings = (element, fragment) => {
|
|
377
377
|
newNode.data = signal();
|
378
378
|
});
|
379
379
|
} else if (signal !== void 0 && newNode instanceof DocumentFragment) {
|
380
|
+
let init = false;
|
380
381
|
createEffect(() => {
|
381
382
|
const result = signal();
|
382
383
|
const nextNode = createNewNode(result, element);
|
@@ -386,14 +387,28 @@ var evaluateBindings = (element, fragment) => {
|
|
386
387
|
);
|
387
388
|
}
|
388
389
|
let lastSibling = element.lastChild;
|
390
|
+
for (const child2 of element.children) {
|
391
|
+
const key = child2.getAttribute("key");
|
392
|
+
if (key === null) continue;
|
393
|
+
const matchingNode = nextNode.querySelector(`[key="${key}"]`);
|
394
|
+
if (init && matchingNode === null) {
|
395
|
+
child2.remove();
|
396
|
+
}
|
397
|
+
}
|
389
398
|
for (const child2 of nextNode.children) {
|
390
399
|
const key = child2.getAttribute("key");
|
391
400
|
const matchingNode = element.querySelector(`[key="${key}"]`);
|
392
401
|
if (matchingNode === null) continue;
|
402
|
+
matchingNode.__customCallbackFns = child2.__customCallbackFns;
|
403
|
+
for (const attr of child2.attributes) {
|
404
|
+
matchingNode.setAttribute(attr.name, attr.value);
|
405
|
+
}
|
406
|
+
matchingNode.replaceChildren(...child2.childNodes);
|
393
407
|
lastSibling = matchingNode.nextSibling;
|
394
408
|
child2.replaceWith(matchingNode);
|
395
409
|
}
|
396
410
|
element.insertBefore(nextNode, lastSibling);
|
411
|
+
if (!init) init = true;
|
397
412
|
});
|
398
413
|
}
|
399
414
|
});
|
@@ -655,8 +670,9 @@ var customElement = (render, options) => {
|
|
655
670
|
get: (_, prop) => {
|
656
671
|
if (!(prop in this.#propSignals)) this.#propSignals[prop] = createSignal();
|
657
672
|
const [_getter, _setter] = this.#propSignals[prop];
|
673
|
+
let setFromProp = false;
|
658
674
|
const setter = (newValue) => {
|
659
|
-
this[prop] = newValue;
|
675
|
+
if (!setFromProp) this[prop] = newValue;
|
660
676
|
_setter(newValue);
|
661
677
|
};
|
662
678
|
const getter = () => {
|
@@ -673,6 +689,14 @@ You must set an initial value before calling a property signal's getter.
|
|
673
689
|
return value;
|
674
690
|
};
|
675
691
|
getter.getter = true;
|
692
|
+
Object.defineProperty(this, prop, {
|
693
|
+
get: getter,
|
694
|
+
set: (newValue) => {
|
695
|
+
setFromProp = true;
|
696
|
+
_setter(newValue);
|
697
|
+
setFromProp = false;
|
698
|
+
}
|
699
|
+
});
|
676
700
|
return [getter, setter];
|
677
701
|
},
|
678
702
|
set: () => {
|
package/dist/index.js
CHANGED
@@ -342,6 +342,7 @@ var evaluateBindings = (element, fragment) => {
|
|
342
342
|
newNode.data = signal();
|
343
343
|
});
|
344
344
|
} else if (signal !== void 0 && newNode instanceof DocumentFragment) {
|
345
|
+
let init = false;
|
345
346
|
createEffect(() => {
|
346
347
|
const result = signal();
|
347
348
|
const nextNode = createNewNode(result, element);
|
@@ -351,14 +352,28 @@ var evaluateBindings = (element, fragment) => {
|
|
351
352
|
);
|
352
353
|
}
|
353
354
|
let lastSibling = element.lastChild;
|
355
|
+
for (const child2 of element.children) {
|
356
|
+
const key = child2.getAttribute("key");
|
357
|
+
if (key === null) continue;
|
358
|
+
const matchingNode = nextNode.querySelector(`[key="${key}"]`);
|
359
|
+
if (init && matchingNode === null) {
|
360
|
+
child2.remove();
|
361
|
+
}
|
362
|
+
}
|
354
363
|
for (const child2 of nextNode.children) {
|
355
364
|
const key = child2.getAttribute("key");
|
356
365
|
const matchingNode = element.querySelector(`[key="${key}"]`);
|
357
366
|
if (matchingNode === null) continue;
|
367
|
+
matchingNode.__customCallbackFns = child2.__customCallbackFns;
|
368
|
+
for (const attr of child2.attributes) {
|
369
|
+
matchingNode.setAttribute(attr.name, attr.value);
|
370
|
+
}
|
371
|
+
matchingNode.replaceChildren(...child2.childNodes);
|
358
372
|
lastSibling = matchingNode.nextSibling;
|
359
373
|
child2.replaceWith(matchingNode);
|
360
374
|
}
|
361
375
|
element.insertBefore(nextNode, lastSibling);
|
376
|
+
if (!init) init = true;
|
362
377
|
});
|
363
378
|
}
|
364
379
|
});
|
@@ -620,8 +635,9 @@ var customElement = (render, options) => {
|
|
620
635
|
get: (_, prop) => {
|
621
636
|
if (!(prop in this.#propSignals)) this.#propSignals[prop] = createSignal();
|
622
637
|
const [_getter, _setter] = this.#propSignals[prop];
|
638
|
+
let setFromProp = false;
|
623
639
|
const setter = (newValue) => {
|
624
|
-
this[prop] = newValue;
|
640
|
+
if (!setFromProp) this[prop] = newValue;
|
625
641
|
_setter(newValue);
|
626
642
|
};
|
627
643
|
const getter = () => {
|
@@ -638,6 +654,14 @@ You must set an initial value before calling a property signal's getter.
|
|
638
654
|
return value;
|
639
655
|
};
|
640
656
|
getter.getter = true;
|
657
|
+
Object.defineProperty(this, prop, {
|
658
|
+
get: getter,
|
659
|
+
set: (newValue) => {
|
660
|
+
setFromProp = true;
|
661
|
+
_setter(newValue);
|
662
|
+
setFromProp = false;
|
663
|
+
}
|
664
|
+
});
|
641
665
|
return [getter, setter];
|
642
666
|
},
|
643
667
|
set: () => {
|