@xaendar/core 0.9.3 → 0.9.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/xaendar-core.es.js +30 -11
- package/package.json +3 -3
package/dist/xaendar-core.es.js
CHANGED
|
@@ -282,7 +282,8 @@ function defineObservedAttributes(klass, context) {
|
|
|
282
282
|
* @param selectors - One or more custom element tag names to associate with the class.
|
|
283
283
|
*/
|
|
284
284
|
function setSelectors(klass, selectors) {
|
|
285
|
-
|
|
285
|
+
if (typeof selectors === "string") customElements.define(selectors, klass);
|
|
286
|
+
else for (let i = 0; i < selectors.length; i++) customElements.define(selectors[i], klass);
|
|
286
287
|
}
|
|
287
288
|
//#endregion
|
|
288
289
|
//#region ../packages/core/src/directives/base-web-component.ts
|
|
@@ -439,7 +440,8 @@ function effect(fn, options) {
|
|
|
439
440
|
queueMicrotask(() => {
|
|
440
441
|
needsEnqueue = true;
|
|
441
442
|
options?.onBeforeRun?.();
|
|
442
|
-
watcher.getPending()
|
|
443
|
+
const pendings = watcher.getPending();
|
|
444
|
+
for (let i = 0; i < pendings.length; i++) pendings[i].get();
|
|
443
445
|
options?.onAfterRun?.();
|
|
444
446
|
watcher.watch();
|
|
445
447
|
});
|
|
@@ -588,7 +590,18 @@ var Context = class {
|
|
|
588
590
|
* @param context - The child context to remove.
|
|
589
591
|
*/
|
|
590
592
|
removeChild(context) {
|
|
591
|
-
|
|
593
|
+
const children = this._children;
|
|
594
|
+
const newChildren = new Array(children.length - 1);
|
|
595
|
+
let i = 0;
|
|
596
|
+
let found = false;
|
|
597
|
+
while (!found) {
|
|
598
|
+
const child = children[i];
|
|
599
|
+
if (child !== context) newChildren[i] = child;
|
|
600
|
+
else found = true;
|
|
601
|
+
i++;
|
|
602
|
+
}
|
|
603
|
+
for (let j = i; j < children.length; j++) newChildren[j - 1] = children[j];
|
|
604
|
+
this._children = newChildren;
|
|
592
605
|
}
|
|
593
606
|
/**
|
|
594
607
|
* Registers a DOM node as directly owned by this context.
|
|
@@ -634,8 +647,8 @@ var Context = class {
|
|
|
634
647
|
* considered disposed and should no longer be used.
|
|
635
648
|
*/
|
|
636
649
|
unlisten() {
|
|
637
|
-
this._unwatchFns.
|
|
638
|
-
this._children.
|
|
650
|
+
for (let i = 0; i < this._unwatchFns.length; i++) this._unwatchFns[i]();
|
|
651
|
+
for (let i = 0; i < this._children.length; i++) this._children[i].unlisten();
|
|
639
652
|
this._unwatchFns = [];
|
|
640
653
|
this._children = [];
|
|
641
654
|
this._nodes = [];
|
|
@@ -723,7 +736,7 @@ function _for(parentNode, parentContext, condition, trackExpression, forFn) {
|
|
|
723
736
|
let entry;
|
|
724
737
|
if (existing) {
|
|
725
738
|
const nodes = existing.context.getNodes();
|
|
726
|
-
if (nodes[nodes.length - 1]?.nextSibling !== nextReference) nodes.
|
|
739
|
+
if (nodes[nodes.length - 1]?.nextSibling !== nextReference) for (let i = 0; i < nodes.length; i++) parentNode.insertBefore(nodes[i], nextReference);
|
|
727
740
|
existing.update?.(i, items);
|
|
728
741
|
entry = existing;
|
|
729
742
|
} else {
|
|
@@ -778,7 +791,11 @@ function _iterationVariables(context, items, index, itemName, aliases) {
|
|
|
778
791
|
$odd.set(newIndex % 2 !== 0);
|
|
779
792
|
}
|
|
780
793
|
};
|
|
781
|
-
Object.entries(retVal.vars)
|
|
794
|
+
const entries = Object.entries(retVal.vars);
|
|
795
|
+
for (let i = 0; i < entries.length; i++) {
|
|
796
|
+
const [key, value] = entries[i];
|
|
797
|
+
context.addIdentifier(key, value);
|
|
798
|
+
}
|
|
782
799
|
return retVal;
|
|
783
800
|
}
|
|
784
801
|
//#endregion
|
|
@@ -944,15 +961,17 @@ function teardown(parentContext, state) {
|
|
|
944
961
|
function _renderElement(parentNode, context, anchor, tagName, attributes, events) {
|
|
945
962
|
const element = context.createElement(tagName);
|
|
946
963
|
mountNode(element, parentNode, context, anchor);
|
|
947
|
-
|
|
964
|
+
for (let i = 0; i < attributes.length; i++) {
|
|
965
|
+
const { name, value, literal } = attributes[i];
|
|
948
966
|
literal ? element.setAttribute(name, String(value())) : context.listen(effect(() => element.setAttribute(name, String(value()))));
|
|
949
|
-
}
|
|
950
|
-
events.
|
|
967
|
+
}
|
|
968
|
+
for (let i = 0; i < events.length; i++) {
|
|
969
|
+
const event = events[i];
|
|
951
970
|
const handler = ($event) => context.getEventHandler(event.handler)(...event.parameters.map((event) => event($event)));
|
|
952
971
|
const name = event.name;
|
|
953
972
|
element.addEventListener(name, handler);
|
|
954
973
|
context.listen(() => element.removeEventListener(name, handler));
|
|
955
|
-
}
|
|
974
|
+
}
|
|
956
975
|
return element;
|
|
957
976
|
}
|
|
958
977
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xaendar/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"description": "A library containing core utils such as webcomponent base classes and theming support",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@xaendar/signals": "0.9.
|
|
20
|
-
"@xaendar/types": "0.9.
|
|
19
|
+
"@xaendar/signals": "0.9.4",
|
|
20
|
+
"@xaendar/types": "0.9.4"
|
|
21
21
|
}
|
|
22
22
|
}
|