@xaendar/core 0.6.12 → 0.6.14
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.d.ts +2 -0
- package/dist/xaendar-core.es.js +13 -4
- package/package.json +3 -3
|
@@ -158,6 +158,8 @@ declare type ContextIdentifier<ReturnType = unknown> = {
|
|
|
158
158
|
reactive: boolean;
|
|
159
159
|
};
|
|
160
160
|
|
|
161
|
+
export declare function declareConst(context: Context, name: string, expression: NoArgsFunction<unknown>): void;
|
|
162
|
+
|
|
161
163
|
/**
|
|
162
164
|
* Runs a side-effectful function and automatically re-runs it whenever any
|
|
163
165
|
* Signal read during its execution changes.
|
package/dist/xaendar-core.es.js
CHANGED
|
@@ -454,7 +454,7 @@ var Context = class {
|
|
|
454
454
|
};
|
|
455
455
|
}
|
|
456
456
|
getEventHandler(handler) {
|
|
457
|
-
return this._root[handler];
|
|
457
|
+
return this._root[handler].bind(this._root);
|
|
458
458
|
}
|
|
459
459
|
addChild(context) {
|
|
460
460
|
this._children.push(context);
|
|
@@ -479,6 +479,11 @@ var Context = class {
|
|
|
479
479
|
}
|
|
480
480
|
};
|
|
481
481
|
//#endregion
|
|
482
|
+
//#region ../packages/core/src/utils/declare-const.util.ts
|
|
483
|
+
function declareConst(context, name, expression) {
|
|
484
|
+
context.addIdentifier(name, expression);
|
|
485
|
+
}
|
|
486
|
+
//#endregion
|
|
482
487
|
//#region ../packages/core/src/utils/for.util.ts
|
|
483
488
|
/**
|
|
484
489
|
* Reactively iterates over a list of items, re-running the loop whenever the tracked condition changes.
|
|
@@ -590,7 +595,11 @@ function _if(parentNode, parentContext, blocks) {
|
|
|
590
595
|
*/
|
|
591
596
|
function handleIf(parentNode, parentContext, ifBlock, state) {
|
|
592
597
|
if (ifBlock.condition()) return checkAndUpdateState(parentNode, parentContext, state, 0, ifBlock.block);
|
|
593
|
-
else
|
|
598
|
+
else if (state) {
|
|
599
|
+
const context = state.context;
|
|
600
|
+
context.unlisten();
|
|
601
|
+
parentContext.removeChild(context);
|
|
602
|
+
}
|
|
594
603
|
}
|
|
595
604
|
/**
|
|
596
605
|
* Handles the `if` / `else` case (exactly two branches).
|
|
@@ -706,7 +715,7 @@ function _renderElement(parentNode, context, tagName, attributes, events) {
|
|
|
706
715
|
}
|
|
707
716
|
});
|
|
708
717
|
events.forEach((event) => {
|
|
709
|
-
const handler = ($event) => context.getEventHandler(event.handler);
|
|
718
|
+
const handler = ($event) => context.getEventHandler(event.handler)();
|
|
710
719
|
const name = event.name;
|
|
711
720
|
element.addEventListener(name, handler);
|
|
712
721
|
context.listen(() => element.removeEventListener(name, handler));
|
|
@@ -747,4 +756,4 @@ function _switch(parentNode, parentContext, expression, blocks) {
|
|
|
747
756
|
})));
|
|
748
757
|
}
|
|
749
758
|
//#endregion
|
|
750
|
-
export { BaseWebComponent, Context, Event, Property, WebComponent, _for, _if, _iterationVariables, _renderElement, _renderLiteralText, _renderText, _switch, computed, effect, input, signal };
|
|
759
|
+
export { BaseWebComponent, Context, Event, Property, WebComponent, _for, _if, _iterationVariables, _renderElement, _renderLiteralText, _renderText, _switch, computed, declareConst, effect, input, signal };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xaendar/core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.14",
|
|
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.6.
|
|
20
|
-
"@xaendar/types": "0.6.
|
|
19
|
+
"@xaendar/signals": "0.6.14",
|
|
20
|
+
"@xaendar/types": "0.6.14"
|
|
21
21
|
}
|
|
22
22
|
}
|