@swiftwc/ui 0.0.0-dev.68 → 0.0.0-dev.69

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.
@@ -45,10 +45,7 @@ function createInstance(prepared) {
45
45
  if (descriptorIndex >= descriptors.length)
46
46
  break;
47
47
  if (node.nodeType === Node.COMMENT_NODE && node.data === MARKER) {
48
- const start = node;
49
- const end = document.createComment(MARKER);
50
- start.after(end);
51
- parts.push({ type: 'child', start, end, committed: undefined });
48
+ parts.push({ type: 'child', anchor: node, nodes: [], committed: undefined });
52
49
  descriptorIndex++;
53
50
  }
54
51
  else if (node.nodeType === Node.ELEMENT_NODE) {
@@ -86,17 +83,16 @@ function toNode(value) {
86
83
  function commitChild(part, value) {
87
84
  if (value === part.committed)
88
85
  return; // dirty-check, skip untouched parts
89
- // clear everything between start/end
90
- let n = part.start.nextSibling;
91
- while (n && n !== part.end) {
92
- const next = n.nextSibling;
86
+ for (const n of part.nodes)
93
87
  n.remove();
94
- n = next;
95
- }
88
+ const nodes = [];
96
89
  for (const item of Array.isArray(value) ? value : [value]) {
97
90
  if (item === null || item === undefined || item === false)
98
91
  continue;
99
- part.end.before(toNode(item));
92
+ const node = toNode(item);
93
+ const inserted = node instanceof DocumentFragment ? Array.from(node.childNodes) : [node];
94
+ part.anchor.before(node);
95
+ nodes.push(...inserted);
100
96
  }
101
97
  part.committed = value;
102
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swiftwc/ui",
3
- "version": "0.0.0-dev.68",
3
+ "version": "0.0.0-dev.69",
4
4
  "description": "Elegant SwiftUI-inspired web components for standalone web apps and web extensions.",
5
5
  "publishConfig": {
6
6
  "access": "public"