@snupo/jmc 1.0.23 → 1.0.25

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/jmc.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"jmc.d.ts","sourceRoot":"","sources":["../src/jmc.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,CAAC,EAAY,cAAc,EAAE,CAAC,EAAE,QAAQ,EAA6B,MAAM,KAAK,CAAA;AAO9F,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,IAAI;QACV,CAAC,CAAC,EAAE,CAAC,GAAG;YAAE,CAAC,CAAC,EAAE,CAAC,CAAA;SAAE,CAAA;KACpB;CACJ;AAkID,wBAAgB,KAAK,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,GAAS,cAAc,QAerE;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAmC;AAC7G,wBAAgB,UAAU,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAoC"}
1
+ {"version":3,"file":"jmc.d.ts","sourceRoot":"","sources":["../src/jmc.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,CAAC,EAAY,cAAc,EAAE,CAAC,EAAE,QAAQ,EAA6B,MAAM,KAAK,CAAA;AAO9F,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,IAAI;QACV,CAAC,CAAC,EAAE,CAAC,GAAG;YAAE,CAAC,CAAC,EAAE,CAAC,CAAA;SAAE,CAAA;KACpB;CACJ;AAkID,wBAAgB,KAAK,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,GAAS,cAAc,QAMrE;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAmC;AAC7G,wBAAgB,UAAU,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAoC"}
package/dist/jmc.js CHANGED
@@ -56,7 +56,7 @@ function sync(uc, parent, i, h, ns) {
56
56
  }
57
57
  else {
58
58
  n = c;
59
- setprops(n, n.h?.p, p); // tbd: this is wrong - try to break this with property updates, just patch sequences - create an own patch test file
59
+ setprops(n, n.h?.p, p);
60
60
  if (p?.update?.(c, uc))
61
61
  return i + 1;
62
62
  }
@@ -99,7 +99,7 @@ function sync(uc, parent, i, h, ns) {
99
99
  ci.mounted?.();
100
100
  return j;
101
101
  }
102
- case undefined:
102
+ default:
103
103
  // textnode
104
104
  let s = h.toString();
105
105
  if (c?.nodeType == 3 /* NodeType.TextNode */) {
@@ -117,17 +117,9 @@ export function patch(e, h, uc = {}) {
117
117
  return;
118
118
  if (uc.replace)
119
119
  e.replaceChildren();
120
- // walk up
121
- while (!h && e)
122
- h = (e = e.parentNode)?.h;
123
- if (!h || !e) {
124
- console.warn("patch not possible, h is undefined in whole parent chain", e, h);
125
- return;
126
- }
127
120
  let p = e.parentElement;
128
121
  let i = [].indexOf.call(p.childNodes, e);
129
- // always called deferred, because removing elements can trigger events and their handlers (like blur)
130
- sync(uc, p, i, h, p.namespaceURI); // is this safe? use default html namespace?
122
+ sync(uc, p, i, h, p.namespaceURI);
131
123
  }
132
124
  export function updateviewuc(u, ...sels) { updateviewinternal(u, ...sels); }
133
125
  export function updateview(...sels) { updateviewinternal({}, ...sels); }
@@ -137,5 +129,4 @@ function updateviewinternal(uc, ...sels) {
137
129
  sels.flatMap(s => (typeof s == 'string' ? [...document.querySelectorAll(s)] : s ? [s] : []))
138
130
  .forEach(e => { patch(e, e.h, uc); });
139
131
  }
140
- // console.log("jmc version 1.0.16");
141
132
  //# sourceMappingURL=jmc.js.map
package/dist/jmc.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"jmc.js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A;IACtC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAgB,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAA;IACvD,sGAAsG;IACtG,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,YAAa,CAAC,CAAA,CAAC,4CAA4C;AACnF,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,CAAiB,EAAE,GAAG,IAAgB,IAAU,kBAAkB,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAA,CAAC,CAAC;AAC7G,MAAM,UAAU,UAAU,CAAC,GAAG,IAAgB,IAAU,kBAAkB,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAA,CAAC,CAAC;AAEzF,SAAS,kBAAkB,CAAC,EAAkB,EAAE,GAAG,IAAgB;IAC/D,IAAI,CAAC,IAAI,CAAC,MAAM;QAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACnC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SACvF,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC,CAAA;AAC5C,CAAC;AAED,qCAAqC","sourcesContent":["import { rebind } from './base.js'\r\nimport type { H, HElement, IUpdateContext, J, Selector, Children, HClassComponent } from './h'\r\nimport { HKind } from './h'\r\n\r\nconst enum NodeType { // vaporizes (but for that must be in this file, otherwise not)\r\n TextNode = 3\r\n}\r\n\r\ndeclare global {\r\n interface Node {\r\n h?: H & { p?: J }\r\n }\r\n}\r\n\r\nlet removeexcesschildren = (n: Element, i: number) => {\r\n let c: ChildNode\r\n while ((c = n.childNodes[i])) {\r\n try { c.remove() } catch (_) { } // due to blur-event-handlers, this can fail\r\n }\r\n}\r\n\r\nlet iswebcomponent = (h: HElement) => h.tag.includes('-')\r\n\r\nconst isproperty = (e: Element, name: string, value: any) =>\r\n name !== \"viewBox\" &&\r\n (value instanceof Object ||\r\n value instanceof Function ||\r\n (e.namespaceURI !== \"http://www.w3.org/2000/svg\" && name in e && name != 'style'))\r\n\r\nlet setprops = (e: Element & J, old: J | undefined, now: J | undefined) => {\r\n\r\n old ??= {}\r\n now ??= {}\r\n\r\n // removals\r\n for (let p in old)\r\n if (!(p in now))\r\n isproperty(e, p, old[p])\r\n ? e[p] = typeof old[p] === 'boolean' ? false : ''\r\n : e.removeAttribute(p)\r\n // updates\r\n for (let p in now) {\r\n let v = now[p]\r\n if (v != old[p]) {\r\n isproperty(e, p, v)\r\n ? e[p] = v\r\n : e.setAttribute(p, v)\r\n }\r\n }\r\n}\r\n\r\n/** synchronizes children starting at the i-th element. returns the index of the last child synchronized */\r\nlet syncchildren = (uc: IUpdateContext, p: Element, cn: Children, i: number, ns: string): number => {\r\n cn.flat().forEach(hc => (i = sync(uc, p, i, hc, ns)))\r\n return i\r\n}\r\n\r\nfunction sync(uc: IUpdateContext, parent: Element, i: number, h: H | undefined, ns: string): number {\r\n\r\n // console.log('%csync2', \"background:orange\", parent.tagName, i, h)\r\n\r\n if (h === null || h === undefined) return i // skip. keep 0 and false renderable, per comment below\r\n let c = parent.childNodes[i]\r\n\r\n switch (h.kind) {\r\n case HKind.Element:\r\n {\r\n let n: Element\r\n let { tag, cn, p } = h\r\n cn ??= []\r\n\r\n if ((<Element>c)?.tagName?.toLowerCase() != tag.toLowerCase()) {\r\n n = document.createElementNS(ns = p?.xmlns ?? ns, tag) // replace namespace with propertyvalue if set. otherwise pass forward to children\r\n c ? c.replaceWith(n) : parent.appendChild(n)\r\n setprops(n, {}, p)\r\n p?.mounted?.(n)\r\n } else {\r\n n = c as Element\r\n setprops(n, n.h?.p, p) // tbd: this is wrong - try to break this with property updates, just patch sequences - create an own patch test file\r\n if (p?.update?.(c, uc)) return i + 1\r\n }\r\n\r\n n.h = h // sets the new property values\r\n\r\n if (!uc.patchElementOnly && !iswebcomponent(h as HElement)) {\r\n\r\n // island attribute\r\n if (n.h?.p?.const) return i + 1\r\n\r\n const j = syncchildren(uc, n, cn, 0, ns)\r\n removeexcesschildren(n, j)\r\n }\r\n\r\n return i + 1\r\n }\r\n\r\n case HKind.Fragment:\r\n {\r\n return syncchildren(uc, parent, h.cn ?? [], i, ns)\r\n }\r\n\r\n case HKind.FunctionComponent:\r\n {\r\n let hr = h.tag(h.p, h.cn)\r\n let j = sync(uc, parent, i, hr, ns)\r\n let n = parent.childNodes[i]! // now the dom element exists, unless the function returned undefined or null\r\n if (n) n.h = h\r\n return j\r\n }\r\n\r\n case HKind.ClassComponent: {\r\n let isupdate = (c?.h as any)?.tag == h.tag\r\n\r\n if (isupdate) {\r\n let ci = (c!.h as HClassComponent).i!\r\n ci.props = h.p\r\n\r\n // update() substitutes view/sync when returning truthy\r\n return (ci.update?.(uc)) ? i + 1 : sync(uc, parent, i, ci.view(), ns)\r\n }\r\n\r\n let ci = h.i = rebind(new h.tag(h.p))\r\n let j = sync(uc, parent, i, ci.view(), ns)\r\n let n = parent.childNodes[i]!\r\n ci.element = n\r\n n.h = h\r\n ci.mounted?.()\r\n return j\r\n }\r\n\r\n case undefined:\r\n // textnode\r\n let s = h.toString()\r\n if (c?.nodeType == NodeType.TextNode) {\r\n if (c.textContent != s) c.textContent = s // firefox updates equal text, loosing existing text selection\r\n } else {\r\n c ? c.replaceWith(s) : parent.append(s)\r\n }\r\n return i + 1\r\n }\r\n}\r\n\r\nexport function patch(e: Node | null, h?: H, uc = {} as IUpdateContext) {\r\n if (!e) return\r\n if (uc.replace) (e as HTMLElement).replaceChildren()\r\n\r\n // walk up\r\n while (!h && e) h = (e = e.parentNode)?.h\r\n if (!h || !e) {\r\n console.warn(\"patch not possible, h is undefined in whole parent chain\", e, h)\r\n return\r\n }\r\n\r\n let p = e.parentElement as HTMLElement\r\n let i = [].indexOf.call<any, any, any>(p.childNodes, e)\r\n // always called deferred, because removing elements can trigger events and their handlers (like blur)\r\n sync(uc, p, i, h, p.namespaceURI!) // is this safe? use default html namespace?\r\n}\r\n\r\nexport function updateviewuc(u: IUpdateContext, ...sels: Selector[]): void { updateviewinternal(u, ...sels) }\r\nexport function updateview(...sels: Selector[]): void { updateviewinternal({}, ...sels) }\r\n\r\nfunction updateviewinternal(uc: IUpdateContext, ...sels: Selector[]): void {\r\n if (!sels.length) sels.push('body')\r\n sels.flatMap(s => (typeof s == 'string' ? [...document.querySelectorAll(s)] : s ? [s] : []))\r\n .forEach(e => { patch(e, e.h, uc) })\r\n}\r\n\r\n// console.log(\"jmc version 1.0.16\");\r\n"]}
1
+ {"version":3,"file":"jmc.js","sourceRoot":"","sources":["../src/jmc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAclC,IAAI,oBAAoB,GAAG,CAAC,CAAU,EAAE,CAAS,EAAE,EAAE;IACjD,IAAI,CAAY,CAAA;IAChB,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC;YAAC,CAAC,CAAC,MAAM,EAAE,CAAA;QAAC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,4CAA4C;IACjF,CAAC;AACL,CAAC,CAAA;AAED,IAAI,cAAc,GAAG,CAAC,CAAW,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AAEzD,MAAM,UAAU,GAAG,CAAC,CAAU,EAAE,IAAY,EAAE,KAAU,EAAE,EAAE,CACxD,IAAI,KAAK,SAAS;I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CAAC,EAAE,EAAE,CAAC,CAAA,CAAC,CAAC,CAAC,CAAA;AAC5C,CAAC","sourcesContent":["import { rebind } from './base.js'\r\nimport type { H, HElement, IUpdateContext, J, Selector, Children, HClassComponent } from './h'\r\nimport { HKind } from './h'\r\n\r\nconst enum NodeType { // vaporizes (but for that must be in this file, otherwise not)\r\n TextNode = 3\r\n}\r\n\r\ndeclare global {\r\n interface Node {\r\n h?: H & { p?: J }\r\n }\r\n}\r\n\r\nlet removeexcesschildren = (n: Element, i: number) => {\r\n let c: ChildNode\r\n while ((c = n.childNodes[i])) {\r\n try { c.remove() } catch (_) { } // due to blur-event-handlers, this can fail\r\n }\r\n}\r\n\r\nlet iswebcomponent = (h: HElement) => h.tag.includes('-')\r\n\r\nconst isproperty = (e: Element, name: string, value: any) =>\r\n name !== \"viewBox\" &&\r\n (value instanceof Object ||\r\n value instanceof Function ||\r\n (e.namespaceURI !== \"http://www.w3.org/2000/svg\" && name in e && name != 'style'))\r\n\r\nlet setprops = (e: Element & J, old: J | undefined, now: J | undefined) => {\r\n\r\n old ??= {}\r\n now ??= {}\r\n\r\n // removals\r\n for (let p in old)\r\n if (!(p in now))\r\n isproperty(e, p, old[p])\r\n ? e[p] = typeof old[p] === 'boolean' ? false : ''\r\n : e.removeAttribute(p)\r\n // updates\r\n for (let p in now) {\r\n let v = now[p]\r\n if (v != old[p]) {\r\n isproperty(e, p, v)\r\n ? e[p] = v\r\n : e.setAttribute(p, v)\r\n }\r\n }\r\n}\r\n\r\n/** synchronizes children starting at the i-th element. returns the index of the last child synchronized */\r\nlet syncchildren = (uc: IUpdateContext, p: Element, cn: Children, i: number, ns: string): number => {\r\n cn.flat().forEach(hc => (i = sync(uc, p, i, hc, ns)))\r\n return i\r\n}\r\n\r\nfunction sync(uc: IUpdateContext, parent: Element, i: number, h: H | undefined, ns: string): number {\r\n\r\n // console.log('%csync2', \"background:orange\", parent.tagName, i, h)\r\n\r\n if (h === null || h === undefined) return i // skip. keep 0 and false renderable, per comment below\r\n let c = parent.childNodes[i]\r\n\r\n switch (h.kind) {\r\n case HKind.Element:\r\n {\r\n let n: Element\r\n let { tag, cn, p } = h\r\n cn ??= []\r\n\r\n if ((<Element>c)?.tagName?.toLowerCase() != tag.toLowerCase()) {\r\n n = document.createElementNS(ns = p?.xmlns ?? ns, tag) // replace namespace with propertyvalue if set. otherwise pass forward to children\r\n c ? c.replaceWith(n) : parent.appendChild(n)\r\n setprops(n, {}, p)\r\n p?.mounted?.(n)\r\n } else {\r\n n = c as Element\r\n setprops(n, n.h?.p, p)\r\n if (p?.update?.(c, uc)) return i + 1\r\n }\r\n\r\n n.h = h // sets the new property values\r\n\r\n if (!uc.patchElementOnly && !iswebcomponent(h as HElement)) {\r\n\r\n // island attribute\r\n if (n.h?.p?.const) return i + 1\r\n\r\n const j = syncchildren(uc, n, cn, 0, ns)\r\n removeexcesschildren(n, j)\r\n }\r\n\r\n return i + 1\r\n }\r\n\r\n case HKind.Fragment:\r\n {\r\n return syncchildren(uc, parent, h.cn ?? [], i, ns)\r\n }\r\n\r\n case HKind.FunctionComponent:\r\n {\r\n let hr = h.tag(h.p, h.cn)\r\n let j = sync(uc, parent, i, hr, ns)\r\n let n = parent.childNodes[i]! // now the dom element exists, unless the function returned undefined or null\r\n if (n) n.h = h\r\n return j\r\n }\r\n\r\n case HKind.ClassComponent: {\r\n let isupdate = (c?.h as any)?.tag == h.tag\r\n\r\n if (isupdate) {\r\n let ci = (c!.h as HClassComponent).i!\r\n ci.props = h.p\r\n\r\n // update() substitutes view/sync when returning truthy\r\n return (ci.update?.(uc)) ? i + 1 : sync(uc, parent, i, ci.view(), ns)\r\n }\r\n\r\n let ci = h.i = rebind(new h.tag(h.p))\r\n let j = sync(uc, parent, i, ci.view(), ns)\r\n let n = parent.childNodes[i]!\r\n ci.element = n\r\n n.h = h\r\n ci.mounted?.()\r\n return j\r\n }\r\n\r\n default:\r\n // textnode\r\n let s = h.toString()\r\n if (c?.nodeType == NodeType.TextNode) {\r\n if (c.textContent != s) c.textContent = s // firefox updates equal text, loosing existing text selection\r\n } else {\r\n c ? c.replaceWith(s) : parent.append(s)\r\n }\r\n return i + 1\r\n }\r\n}\r\n\r\nexport function patch(e: Node | null, h?: H, uc = {} as IUpdateContext) {\r\n if (!e) return\r\n if (uc.replace) (e as HTMLElement).replaceChildren()\r\n let p = e.parentElement as HTMLElement\r\n let i = [].indexOf.call<any, any, any>(p.childNodes, e)\r\n sync(uc, p, i, h, p.namespaceURI!)\r\n}\r\n\r\nexport function updateviewuc(u: IUpdateContext, ...sels: Selector[]): void { updateviewinternal(u, ...sels) }\r\nexport function updateview(...sels: Selector[]): void { updateviewinternal({}, ...sels) }\r\n\r\nfunction updateviewinternal(uc: IUpdateContext, ...sels: Selector[]): void {\r\n if (!sels.length) sels.push('body')\r\n sels.flatMap(s => (typeof s == 'string' ? [...document.querySelectorAll(s)] : s ? [s] : []))\r\n .forEach(e => { patch(e, e.h, uc) })\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@snupo/jmc",
3
3
  "author": "snupo",
4
- "version": "1.0.23",
4
+ "version": "1.0.25",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -19,15 +19,9 @@
19
19
  "src"
20
20
  ],
21
21
  "devDependencies": {
22
- "typescript": "^6.0.3",
23
- "vite": "^8.1.5",
24
- "vitest": "4.1.10",
25
- "happy-dom": "^16.8.1",
26
- "@vitest/coverage-v8": "^4.1.10",
27
- "rimraf": "^6.1.3"
28
- },
29
- "dependencies": {
30
- "@types/react": "^19.2.17"
22
+ "@types/react": "^19.2.17",
23
+ "rimraf": "^6.1.3",
24
+ "typescript": "^6.0.3"
31
25
  },
32
26
  "scripts": {
33
27
  "prebuild": "rimraf dist",
package/readme.md ADDED
@@ -0,0 +1,34 @@
1
+ embrace typescript
2
+ embrace jsx / tsx
3
+ simplicity to a level where everybody can read, fix, expand the code
4
+
5
+ 1. model
6
+ - is a pojo
7
+ no magic as in vue or svelte
8
+ no insane functional optics and lenses, no toolkits, needed to change a property value in the state
9
+ no proxificiation of the pojo, just the instance must remain stable
10
+
11
+ 2. controller
12
+ - only the controller modifies the model, which shall be treated immutable for other code parts like the view
13
+ - controller actions modify the model and update the relevant parts of the view.
14
+ while this need to consider which parts of the view require an update after the current action,
15
+ this causes only minimal effort to the programmer - in contrast to the "reactive" frameworks who try to free
16
+ the programmer from this task not considering the complexity they add during this endeavour:
17
+ no inefficient comparisons between old and new state as in react-redux glue code
18
+ no magic as in vue or svelte, sooner or later one needs to understand the hidden magic operations
19
+
20
+ 3. view
21
+ - is the dom, described as statically typed jsx, namely tsx
22
+ typescript compiler team went to incredible heights making jsx perfectly safe.
23
+ writing the view is to a good part similar as in react, having invented jsx from hyperscript is the good part of react
24
+ - updates of the the view can be as fine granular as desired, their scope is specified by a dom element
25
+ - while jsx expression are traditionally transformed into virtual dom representations that are then syncd with the real dome,
26
+ jmx avoids the cost of a virtual dom. instead, jsx expressions are transformed into update functions that take the real dom
27
+ element as argument and sync that element when called.
28
+
29
+ since the model is just a pojo and the controller a plane class with methods for the applications operations, the only missing piece is the specific jsx view.
30
+ the jmx library therefore provides:
31
+ a vite plugin that transforms the js code for jsx fragments a little bit
32
+ a real dom update system that has similarities with v-dom libraries, and equals their rather low complexity
33
+
34
+ in addition to that library, jmx provides a style guide on how to write js applications (a strict layer pattern), how to debug them and finally a simple router.
package/src/jmc.ts CHANGED
@@ -76,7 +76,7 @@ function sync(uc: IUpdateContext, parent: Element, i: number, h: H | undefined,
76
76
  p?.mounted?.(n)
77
77
  } else {
78
78
  n = c as Element
79
- setprops(n, n.h?.p, p) // tbd: this is wrong - try to break this with property updates, just patch sequences - create an own patch test file
79
+ setprops(n, n.h?.p, p)
80
80
  if (p?.update?.(c, uc)) return i + 1
81
81
  }
82
82
 
@@ -128,7 +128,7 @@ function sync(uc: IUpdateContext, parent: Element, i: number, h: H | undefined,
128
128
  return j
129
129
  }
130
130
 
131
- case undefined:
131
+ default:
132
132
  // textnode
133
133
  let s = h.toString()
134
134
  if (c?.nodeType == NodeType.TextNode) {
@@ -143,18 +143,9 @@ function sync(uc: IUpdateContext, parent: Element, i: number, h: H | undefined,
143
143
  export function patch(e: Node | null, h?: H, uc = {} as IUpdateContext) {
144
144
  if (!e) return
145
145
  if (uc.replace) (e as HTMLElement).replaceChildren()
146
-
147
- // walk up
148
- while (!h && e) h = (e = e.parentNode)?.h
149
- if (!h || !e) {
150
- console.warn("patch not possible, h is undefined in whole parent chain", e, h)
151
- return
152
- }
153
-
154
146
  let p = e.parentElement as HTMLElement
155
147
  let i = [].indexOf.call<any, any, any>(p.childNodes, e)
156
- // always called deferred, because removing elements can trigger events and their handlers (like blur)
157
- sync(uc, p, i, h, p.namespaceURI!) // is this safe? use default html namespace?
148
+ sync(uc, p, i, h, p.namespaceURI!)
158
149
  }
159
150
 
160
151
  export function updateviewuc(u: IUpdateContext, ...sels: Selector[]): void { updateviewinternal(u, ...sels) }
@@ -165,5 +156,3 @@ function updateviewinternal(uc: IUpdateContext, ...sels: Selector[]): void {
165
156
  sels.flatMap(s => (typeof s == 'string' ? [...document.querySelectorAll(s)] : s ? [s] : []))
166
157
  .forEach(e => { patch(e, e.h, uc) })
167
158
  }
168
-
169
- // console.log("jmc version 1.0.16");