webdetta 0.1.238 → 0.1.240

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": "webdetta",
3
- "version": "0.1.238",
3
+ "version": "0.1.240",
4
4
  "author": "Fedot Kriutchenko <fodyadev@gmail.com>",
5
5
  "description": "",
6
6
  "license": "MIT",
@@ -82,11 +82,9 @@ Element.remove = (node) => {
82
82
  afterRemove.get(node)?.();
83
83
  }
84
84
 
85
- export const Operator = (...funcs) => Builder((tasks, node) => {
85
+ export const Operator = (func, { track=true }={}) => Builder((tasks, node) => {
86
86
  for (const {names, args} of tasks) {
87
- for (const func of funcs) {
88
- r.effect(() => func(node, names, args));
89
- }
87
+ r.effect(() => func(node, names, args), { track });
90
88
  }
91
89
  });
92
90
  Operator.isOperator = Builder.isBuilder;
@@ -10,7 +10,7 @@ const api = {};
10
10
 
11
11
  api.ref = Operator((node, _, args) => {
12
12
  for (const func of args) func(node);
13
- });
13
+ }, { track: false });
14
14
 
15
15
  api.parse = (...args) => {
16
16
  const div = document.createElement('div');
@@ -11,6 +11,7 @@ const RouterRealdom = ({
11
11
  const currentRoute = r.val();
12
12
  const loadedRoutes = r.val(new Map());
13
13
  const listener = ({ key, value: page, params }) => {
14
+ // 2
14
15
  const loaded = loadedRoutes();
15
16
  const paramKeys = Object.keys({ ...params, ...(paramVals[key] ?? {}) });
16
17
  for (const param of paramKeys) {
@@ -28,17 +29,18 @@ const RouterRealdom = ({
28
29
  loadedRoutes(loaded);
29
30
  currentRoute(key);
30
31
  }
31
- router.listen((...a) => r.untrack(listener.bind(null, ...a)));
32
+ router.listen((...a) => {
33
+ // 1
34
+ r.untrack(listener.bind(null, ...a));
35
+ });
32
36
  router.attach();
33
37
 
34
- const container = el[':'](
35
- el.list(loadedRoutes, ({ key, dom }) => {
36
- const isVisible = () => currentRoute() == key;
37
- return el.append(dom,
38
- el.if(() => !isVisible(), el.style.display`none`),
39
- );
40
- })
41
- );
38
+ const container = el.list(loadedRoutes, ({ key, dom }) => {
39
+ const isVisible = () => currentRoute() == key;
40
+ return el.append(dom,
41
+ el.if(() => !isVisible(), el.style.display`none`),
42
+ );
43
+ });
42
44
  return { container, router };
43
45
  };
44
46
  RouterRealdom.ctx = Context();