@solidjs/web 2.0.0-rc.17 → 2.0.0-rc.19

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/web.js CHANGED
@@ -71,10 +71,21 @@ function memo(fn) {
71
71
  }
72
72
 
73
73
  function reconcileArrays(parentNode, a, b, marker) {
74
+ let active = parentNode.moveBefore && parentNode.isConnected && document.activeElement;
75
+ if (active === document.body) active = null;
76
+ const slot = marker || parentNode;
77
+ const insert = (n, ref) => {
78
+ active && n.isConnected && n.contains(active) ? parentNode.moveBefore(n, ref) : parentNode.insertBefore(n, ref);
79
+ if (marker || n[$$SLOT]) n[$$SLOT] = slot;
80
+ };
81
+ if (!a.length) {
82
+ for (const n of b) insert(n, marker);
83
+ return;
84
+ }
74
85
  const isLive = n => {
75
86
  if (!n) return false;
76
87
  const tag = n[$$SLOT];
77
- return n.parentNode === parentNode && (!tag || tag === marker);
88
+ return n.parentNode === parentNode && (!tag || tag === slot);
78
89
  };
79
90
  let bLength = b.length,
80
91
  aEnd = a.length,
@@ -97,40 +108,21 @@ function reconcileArrays(parentNode, a, b, marker) {
97
108
  bEnd--;
98
109
  }
99
110
  if (aEnd === aStart) {
100
- let node;
101
- if (bEnd < bLength) {
102
- if (bStart && isLive(node = b[bStart - 1])) node = node.nextSibling;else {
103
- let k = bEnd;
104
- while (k < bLength && !isLive(b[k])) k++;
105
- node = k < bLength ? b[k] : after;
106
- }
107
- } else node = after;
108
- while (bStart < bEnd) {
109
- const n = b[bStart++];
110
- parentNode.insertBefore(n, node);
111
- if (marker) n[$$SLOT] = marker;
112
- }
111
+ let k = bEnd;
112
+ while (k < bLength && !isLive(b[k])) k++;
113
+ const node = k < bLength ? b[k] : after;
114
+ while (bStart < bEnd) insert(b[bStart++], node);
113
115
  } else if (bEnd === bStart) {
114
116
  while (aStart < aEnd) {
115
117
  const n = a[aStart++];
116
118
  if ((!map || !map.has(n)) && isLive(n)) n.remove();
117
119
  }
118
- } else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
119
- if (marker) {
120
- do {
121
- const n = a[--aEnd];
122
- parentNode.insertBefore(n, anchor);
123
- n[$$SLOT] = marker;
124
- bStart++;
125
- if (aStart >= aEnd - 1 || bStart >= bEnd) break;
126
- } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
127
- } else {
128
- do {
129
- parentNode.insertBefore(a[--aEnd], anchor);
130
- bStart++;
131
- if (aStart >= aEnd - 1 || bStart >= bEnd) break;
132
- } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
133
- }
120
+ } else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === slot)) {
121
+ do {
122
+ insert(a[--aEnd], anchor);
123
+ bStart++;
124
+ if (aStart >= aEnd - 1 || bStart >= bEnd) break;
125
+ } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
134
126
  } else {
135
127
  if (!isLive(a[aStart])) {
136
128
  aStart++;
@@ -153,15 +145,12 @@ function reconcileArrays(parentNode, a, b, marker) {
153
145
  }
154
146
  if (sequence > index - bStart) {
155
147
  const node = a[aStart];
156
- while (bStart < index) {
157
- const n = b[bStart++];
158
- parentNode.insertBefore(n, node);
159
- if (marker) n[$$SLOT] = marker;
160
- }
148
+ while (bStart < index) insert(b[bStart++], node);
161
149
  } else {
162
- const newNode = b[bStart++];
163
- parentNode.replaceChild(newNode, a[aStart++]);
164
- if (marker) newNode[$$SLOT] = marker;
150
+ const newNode = b[bStart++],
151
+ node = a[aStart++];
152
+ active && parentNode.contains(active) ? insert(newNode, node) : parentNode.replaceChild(newNode, node);
153
+ if (marker || newNode[$$SLOT]) newNode[$$SLOT] = slot;
165
154
  }
166
155
  } else aStart++;
167
156
  } else a[aStart++].remove();
@@ -1298,7 +1287,7 @@ function gateHeadResource(props) {
1298
1287
  if (attrs) descriptor.attrs = attrs;
1299
1288
  effect(() => {
1300
1289
  const entry = warmAsset(descriptor);
1301
- if (gateable && !sharedConfig.hydrating && entry.loadState === "pending" && typeof waitAsset === "function") waitAsset(entry.loadPromise);
1290
+ if (gateable && !isHydrating() && entry.loadState === "pending" && typeof waitAsset === "function") waitAsset(entry.loadPromise);
1302
1291
  }, () => acquireAsset(descriptor));
1303
1292
  }
1304
1293
  function useHead(tags) {
@@ -1481,10 +1470,9 @@ function hydrate(code, element, options = {}) {
1481
1470
  }
1482
1471
  }
1483
1472
  function getNextElement(template) {
1484
- let node,
1485
- key,
1486
- hydrating = isHydrating();
1487
- if (!hydrating || !(node = sharedConfig.registry.get(key = getHydrationKey()))) {
1473
+ let key = sharedConfig.hydrating && getHydrationKey(),
1474
+ node = isHydrating() && sharedConfig.registry.get(key);
1475
+ if (!node) {
1488
1476
  if (!template) {
1489
1477
  throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}`);
1490
1478
  }
@@ -1564,6 +1552,7 @@ function runHydrationEvents() {
1564
1552
  matches.sort((a, b) => a.distance - b.distance);
1565
1553
  for (let i = 0; i < matches.length; i++) eventHandler(e, matches[i].container, matches[i].state);
1566
1554
  } else if (matchContainer) eventHandler(e, matchContainer, matchState);
1555
+ flush();
1567
1556
  }
1568
1557
  if (sharedConfig.done) {
1569
1558
  sharedConfig.events = _$HY.events = null;
@@ -1678,7 +1667,6 @@ function eventHandler(e, container, state) {
1678
1667
  e[$$EVENT_OWNER] = owner;
1679
1668
  let node = resumeNode || e.target;
1680
1669
  const key = EVENT_KEY + e.type;
1681
- const oriTarget = e.target;
1682
1670
  const retarget = value => Object.defineProperty(e, "target", {
1683
1671
  configurable: true,
1684
1672
  value
@@ -1727,7 +1715,8 @@ function eventHandler(e, container, state) {
1727
1715
  } else walkUpTree();
1728
1716
  }
1729
1717
  else walkUpTree();
1730
- retarget(oriTarget);
1718
+ delete e.target;
1719
+ delete e.currentTarget;
1731
1720
  }
1732
1721
  function insertExpression(parent, value, current, marker) {
1733
1722
  if (hydrationRt !== null && isHydrating(parent)) {
@@ -1772,7 +1761,7 @@ function insertExpression(parent, value, current, marker) {
1772
1761
  } else {
1773
1762
  parent.appendChild(value);
1774
1763
  }
1775
- if (marker) value[$$SLOT] = marker;
1764
+ if (marker || value[$$SLOT]) value[$$SLOT] = marker || parent;
1776
1765
  } else if (Array.isArray(value)) {
1777
1766
  const currentArray = Array.isArray(current);
1778
1767
  for (let i = 0, len = value.length; i < len; i++) {
@@ -1789,12 +1778,10 @@ function insertExpression(parent, value, current, marker) {
1789
1778
  if (value.length === 0) {
1790
1779
  cleanChildren(parent, current, marker);
1791
1780
  } else if (currentArray) {
1792
- if (current.length === 0) {
1793
- appendNodes(parent, value, marker);
1794
- } else reconcileArrays(parent, current, value, marker);
1781
+ reconcileArrays(parent, current, value, marker);
1795
1782
  } else {
1796
1783
  if (current != null) cleanChildren(parent, current);
1797
- appendNodes(parent, value);
1784
+ reconcileArrays(parent, [], value);
1798
1785
  }
1799
1786
  } else ;
1800
1787
  selectInsert && selectInsert(parent);
@@ -1813,18 +1800,19 @@ function writeSelectValue(node, value) {
1813
1800
  return queueMicrotask(() => node.value = value) || (node.value = value);
1814
1801
  }
1815
1802
  node._$v = value;
1816
- (selectInsert ||= p => {
1817
- p && p._$v == null && (p = p.parentNode);
1818
- const v = p && p._$v;
1819
- if (v == null) return;
1820
- if (v.map) {
1821
- const o = [...p.options];
1822
- for (let i = 0; i < o.length; i++) o[i].selected = v.some(x => x == o[i].value);
1823
- v.every(x => o.some(el => el.value == x)) && selectChange(p);
1824
- } else p.value = v, p.selectedIndex > -1 && p.value == v && (p._$v = null);
1825
- })(node);
1803
+ (selectInsert ||= applySelectValue)(node);
1826
1804
  queueMicrotask(() => selectInsert(node));
1827
1805
  }
1806
+ function applySelectValue(p) {
1807
+ p && p._$v == null && (p = p.parentNode);
1808
+ const v = p && p._$v;
1809
+ if (v == null) return;
1810
+ if (v.map) {
1811
+ const o = [...p.options];
1812
+ for (let i = 0; i < o.length; i++) o[i].selected = v.some(x => x == o[i].value);
1813
+ v.every(x => o.some(el => el.value == x)) && selectChange(p);
1814
+ } else p.value = v, p.selectedIndex > -1 && p.value == v && (p._$v = null);
1815
+ }
1828
1816
  function normalize(value, current, multi, doNotUnwrap) {
1829
1817
  value = flatten(value, {
1830
1818
  skipNonRendered: true,
@@ -1853,13 +1841,6 @@ function tagHost(value, host) {
1853
1841
  });
1854
1842
  }
1855
1843
  }
1856
- function appendNodes(parent, array, marker = null) {
1857
- for (let i = 0, len = array.length; i < len; i++) {
1858
- const n = array[i];
1859
- parent.insertBefore(n, marker);
1860
- if (marker) n[$$SLOT] = marker;
1861
- }
1862
- }
1863
1844
  function ownsAllChildren(parent, current) {
1864
1845
  if (current == null) return true;
1865
1846
  if (Array.isArray(current)) {
@@ -1894,12 +1875,12 @@ function cleanChildren(parent, current, marker, replacement) {
1894
1875
  const el = current[i];
1895
1876
  if (replacement !== el) {
1896
1877
  const tag = el[$$SLOT];
1897
- const owns = el.parentNode === parent && (!tag || tag === marker);
1878
+ const owns = el.parentNode === parent && (!tag || tag === (marker || parent));
1898
1879
  if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
1899
1880
  } else inserted = true;
1900
1881
  }
1901
1882
  } else if (replacement) parent.insertBefore(replacement, marker);
1902
- if (replacement && marker) replacement[$$SLOT] = marker;
1883
+ if (replacement && (marker || replacement[$$SLOT])) replacement[$$SLOT] = marker || parent;
1903
1884
  }
1904
1885
  function gatherHydratable(element, root) {
1905
1886
  const templates = element.querySelectorAll(root ? `[_hk^="${root.replace(/["\\]/g, "\\$&")}"]` : `*[_hk]`);
@@ -2156,7 +2137,8 @@ function dynamic(source, options) {
2156
2137
  }
2157
2138
  function staticElement(tag, props) {
2158
2139
  const hydrating = sharedConfig.hydrating;
2159
- const el = hydrating ? getNextElement() : createElement(tag, untrack(() => props.is), untrack(() => props.xmlns));
2140
+ const create = () => createElement(tag, untrack(() => props.is), untrack(() => props.xmlns));
2141
+ const el = hydrating ? getNextElement(create) : create();
2160
2142
  spread(el, props);
2161
2143
  if (hydrating) runHydrationEvents();
2162
2144
  return el;
@@ -82,10 +82,21 @@ function memo(fn) {
82
82
  }
83
83
 
84
84
  function reconcileArrays(parentNode, a, b, marker) {
85
+ let active = parentNode.moveBefore && parentNode.isConnected && document.activeElement;
86
+ if (active === document.body) active = null;
87
+ const slot = marker || parentNode;
88
+ const insert = (n, ref) => {
89
+ active && n.isConnected && n.contains(active) ? parentNode.moveBefore(n, ref) : parentNode.insertBefore(n, ref);
90
+ if (marker || n[$$SLOT]) n[$$SLOT] = slot;
91
+ };
92
+ if (!a.length) {
93
+ for (const n of b) insert(n, marker);
94
+ return;
95
+ }
85
96
  const isLive = n => {
86
97
  if (!n) return false;
87
98
  const tag = n[$$SLOT];
88
- return n.parentNode === parentNode && (!tag || tag === marker);
99
+ return n.parentNode === parentNode && (!tag || tag === slot);
89
100
  };
90
101
  let bLength = b.length,
91
102
  aEnd = a.length,
@@ -108,40 +119,21 @@ function reconcileArrays(parentNode, a, b, marker) {
108
119
  bEnd--;
109
120
  }
110
121
  if (aEnd === aStart) {
111
- let node;
112
- if (bEnd < bLength) {
113
- if (bStart && isLive(node = b[bStart - 1])) node = node.nextSibling;else {
114
- let k = bEnd;
115
- while (k < bLength && !isLive(b[k])) k++;
116
- node = k < bLength ? b[k] : after;
117
- }
118
- } else node = after;
119
- while (bStart < bEnd) {
120
- const n = b[bStart++];
121
- parentNode.insertBefore(n, node);
122
- if (marker) n[$$SLOT] = marker;
123
- }
122
+ let k = bEnd;
123
+ while (k < bLength && !isLive(b[k])) k++;
124
+ const node = k < bLength ? b[k] : after;
125
+ while (bStart < bEnd) insert(b[bStart++], node);
124
126
  } else if (bEnd === bStart) {
125
127
  while (aStart < aEnd) {
126
128
  const n = a[aStart++];
127
129
  if ((!map || !map.has(n)) && isLive(n)) n.remove();
128
130
  }
129
- } else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
130
- if (marker) {
131
- do {
132
- const n = a[--aEnd];
133
- parentNode.insertBefore(n, anchor);
134
- n[$$SLOT] = marker;
135
- bStart++;
136
- if (aStart >= aEnd - 1 || bStart >= bEnd) break;
137
- } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
138
- } else {
139
- do {
140
- parentNode.insertBefore(a[--aEnd], anchor);
141
- bStart++;
142
- if (aStart >= aEnd - 1 || bStart >= bEnd) break;
143
- } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
144
- }
131
+ } else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === slot)) {
132
+ do {
133
+ insert(a[--aEnd], anchor);
134
+ bStart++;
135
+ if (aStart >= aEnd - 1 || bStart >= bEnd) break;
136
+ } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
145
137
  } else {
146
138
  if (!isLive(a[aStart])) {
147
139
  aStart++;
@@ -164,15 +156,12 @@ function reconcileArrays(parentNode, a, b, marker) {
164
156
  }
165
157
  if (sequence > index - bStart) {
166
158
  const node = a[aStart];
167
- while (bStart < index) {
168
- const n = b[bStart++];
169
- parentNode.insertBefore(n, node);
170
- if (marker) n[$$SLOT] = marker;
171
- }
159
+ while (bStart < index) insert(b[bStart++], node);
172
160
  } else {
173
- const newNode = b[bStart++];
174
- parentNode.replaceChild(newNode, a[aStart++]);
175
- if (marker) newNode[$$SLOT] = marker;
161
+ const newNode = b[bStart++],
162
+ node = a[aStart++];
163
+ active && parentNode.contains(active) ? insert(newNode, node) : parentNode.replaceChild(newNode, node);
164
+ if (marker || newNode[$$SLOT]) newNode[$$SLOT] = slot;
176
165
  }
177
166
  } else aStart++;
178
167
  } else a[aStart++].remove();
@@ -1349,7 +1338,7 @@ function gateHeadResource(props) {
1349
1338
  if (attrs) descriptor.attrs = attrs;
1350
1339
  effect(() => {
1351
1340
  const entry = warmAsset(descriptor);
1352
- if (gateable && !sharedConfig.hydrating && entry.loadState === "pending" && typeof waitAsset === "function") waitAsset(entry.loadPromise);
1341
+ if (gateable && !isHydrating() && entry.loadState === "pending" && typeof waitAsset === "function") waitAsset(entry.loadPromise);
1353
1342
  }, () => acquireAsset(descriptor));
1354
1343
  }
1355
1344
  function useHead(tags) {
@@ -1532,10 +1521,9 @@ function hydrate(code, element, options = {}) {
1532
1521
  }
1533
1522
  }
1534
1523
  function getNextElement(template) {
1535
- let node,
1536
- key,
1537
- hydrating = isHydrating();
1538
- if (!hydrating || !(node = sharedConfig.registry.get(key = getHydrationKey()))) {
1524
+ let key = sharedConfig.hydrating && getHydrationKey(),
1525
+ node = isHydrating() && sharedConfig.registry.get(key);
1526
+ if (!node) {
1539
1527
  if (!template) {
1540
1528
  throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}`);
1541
1529
  }
@@ -1615,6 +1603,7 @@ function runHydrationEvents() {
1615
1603
  matches.sort((a, b) => a.distance - b.distance);
1616
1604
  for (let i = 0; i < matches.length; i++) eventHandler(e, matches[i].container, matches[i].state);
1617
1605
  } else if (matchContainer) eventHandler(e, matchContainer, matchState);
1606
+ flush();
1618
1607
  }
1619
1608
  if (sharedConfig.done) {
1620
1609
  sharedConfig.events = _$HY.events = null;
@@ -1729,7 +1718,6 @@ function eventHandler(e, container, state) {
1729
1718
  e[$$EVENT_OWNER] = owner;
1730
1719
  let node = resumeNode || e.target;
1731
1720
  const key = EVENT_KEY + e.type;
1732
- const oriTarget = e.target;
1733
1721
  const retarget = value => Object.defineProperty(e, "target", {
1734
1722
  configurable: true,
1735
1723
  value
@@ -1778,7 +1766,8 @@ function eventHandler(e, container, state) {
1778
1766
  } else walkUpTree();
1779
1767
  }
1780
1768
  else walkUpTree();
1781
- retarget(oriTarget);
1769
+ delete e.target;
1770
+ delete e.currentTarget;
1782
1771
  }
1783
1772
  function insertExpression(parent, value, current, marker) {
1784
1773
  if (hydrationRt !== null && isHydrating(parent)) {
@@ -1823,7 +1812,7 @@ function insertExpression(parent, value, current, marker) {
1823
1812
  } else {
1824
1813
  parent.appendChild(value);
1825
1814
  }
1826
- if (marker) value[$$SLOT] = marker;
1815
+ if (marker || value[$$SLOT]) value[$$SLOT] = marker || parent;
1827
1816
  } else if (Array.isArray(value)) {
1828
1817
  const currentArray = Array.isArray(current);
1829
1818
  for (let i = 0, len = value.length; i < len; i++) {
@@ -1840,12 +1829,10 @@ function insertExpression(parent, value, current, marker) {
1840
1829
  if (value.length === 0) {
1841
1830
  cleanChildren(parent, current, marker);
1842
1831
  } else if (currentArray) {
1843
- if (current.length === 0) {
1844
- appendNodes(parent, value, marker);
1845
- } else reconcileArrays(parent, current, value, marker);
1832
+ reconcileArrays(parent, current, value, marker);
1846
1833
  } else {
1847
1834
  if (current != null) cleanChildren(parent, current);
1848
- appendNodes(parent, value);
1835
+ reconcileArrays(parent, [], value);
1849
1836
  }
1850
1837
  } else ;
1851
1838
  selectInsert && selectInsert(parent);
@@ -1864,18 +1851,19 @@ function writeSelectValue(node, value) {
1864
1851
  return queueMicrotask(() => node.value = value) || (node.value = value);
1865
1852
  }
1866
1853
  node._$v = value;
1867
- (selectInsert ||= p => {
1868
- p && p._$v == null && (p = p.parentNode);
1869
- const v = p && p._$v;
1870
- if (v == null) return;
1871
- if (v.map) {
1872
- const o = [...p.options];
1873
- for (let i = 0; i < o.length; i++) o[i].selected = v.some(x => x == o[i].value);
1874
- v.every(x => o.some(el => el.value == x)) && selectChange(p);
1875
- } else p.value = v, p.selectedIndex > -1 && p.value == v && (p._$v = null);
1876
- })(node);
1854
+ (selectInsert ||= applySelectValue)(node);
1877
1855
  queueMicrotask(() => selectInsert(node));
1878
1856
  }
1857
+ function applySelectValue(p) {
1858
+ p && p._$v == null && (p = p.parentNode);
1859
+ const v = p && p._$v;
1860
+ if (v == null) return;
1861
+ if (v.map) {
1862
+ const o = [...p.options];
1863
+ for (let i = 0; i < o.length; i++) o[i].selected = v.some(x => x == o[i].value);
1864
+ v.every(x => o.some(el => el.value == x)) && selectChange(p);
1865
+ } else p.value = v, p.selectedIndex > -1 && p.value == v && (p._$v = null);
1866
+ }
1879
1867
  function normalize(value, current, multi, doNotUnwrap) {
1880
1868
  value = flatten(value, {
1881
1869
  skipNonRendered: true,
@@ -1904,13 +1892,6 @@ function tagHost(value, host) {
1904
1892
  });
1905
1893
  }
1906
1894
  }
1907
- function appendNodes(parent, array, marker = null) {
1908
- for (let i = 0, len = array.length; i < len; i++) {
1909
- const n = array[i];
1910
- parent.insertBefore(n, marker);
1911
- if (marker) n[$$SLOT] = marker;
1912
- }
1913
- }
1914
1895
  function ownsAllChildren(parent, current) {
1915
1896
  if (current == null) return true;
1916
1897
  if (Array.isArray(current)) {
@@ -1945,12 +1926,12 @@ function cleanChildren(parent, current, marker, replacement) {
1945
1926
  const el = current[i];
1946
1927
  if (replacement !== el) {
1947
1928
  const tag = el[$$SLOT];
1948
- const owns = el.parentNode === parent && (!tag || tag === marker);
1929
+ const owns = el.parentNode === parent && (!tag || tag === (marker || parent));
1949
1930
  if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
1950
1931
  } else inserted = true;
1951
1932
  }
1952
1933
  } else if (replacement) parent.insertBefore(replacement, marker);
1953
- if (replacement && marker) replacement[$$SLOT] = marker;
1934
+ if (replacement && (marker || replacement[$$SLOT])) replacement[$$SLOT] = marker || parent;
1954
1935
  }
1955
1936
  function gatherHydratable(element, root) {
1956
1937
  const templates = element.querySelectorAll(root ? `[_hk^="${root.replace(/["\\]/g, "\\$&")}"]` : `*[_hk]`);
@@ -2207,7 +2188,8 @@ function dynamic(source, options) {
2207
2188
  }
2208
2189
  function staticElement(tag, props) {
2209
2190
  const hydrating = sharedConfig.hydrating;
2210
- const el = hydrating ? getNextElement() : createElement(tag, untrack(() => props.is), untrack(() => props.xmlns));
2191
+ const create = () => createElement(tag, untrack(() => props.is), untrack(() => props.xmlns));
2192
+ const el = hydrating ? getNextElement(create) : create();
2211
2193
  spread(el, props);
2212
2194
  if (hydrating) runHydrationEvents();
2213
2195
  return el;
@@ -224,26 +224,12 @@ function resolveCodecOptions(options = {}) {
224
224
  }
225
225
 
226
226
  const serializeOnlyDisabledFeatures = serializeErrorStacks => (serializeErrorStacks === undefined ? process.env.NODE_ENV === "development" : serializeErrorStacks) ? 0 : Feature.ErrorPrototypeStack;
227
- function createJSONSerializer({
228
- onData,
229
- onDone,
230
- onError,
231
- plugins,
232
- disabledFeatures,
233
- depthLimit,
234
- serializeErrorStacks
235
- }) {
236
- const resolved = resolveCodecOptions({
237
- plugins,
238
- disabledFeatures,
239
- depthLimit,
240
- serializeErrorStacks
241
- });
242
- const refs = new Map();
227
+ function createKeyedSerializer(serialize, onError, onDone) {
243
228
  const cancels = new Set();
244
229
  let pendingWrites = 0;
245
230
  let flushed = false;
246
231
  let done = false;
232
+ let closed = false;
247
233
  const maybeDone = () => {
248
234
  if (flushed && pendingWrites === 0 && !done) {
249
235
  done = true;
@@ -255,42 +241,90 @@ function createJSONSerializer({
255
241
  if (flushed) return;
256
242
  pendingWrites++;
257
243
  let settled = false;
244
+ let failed = false;
245
+ let started = false;
258
246
  let cancel = null;
259
- const stream = toCrossJSONStream(value, {
260
- refs,
261
- plugins: resolved.plugins,
262
- disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures(resolved.serializeErrorStacks),
263
- onParse(node, initial) {
264
- onData({
265
- key,
266
- node,
267
- initial
268
- });
269
- },
270
- onError,
271
- onDone() {
272
- settled = true;
273
- if (cancel) cancels.delete(cancel);
274
- pendingWrites--;
275
- maybeDone();
276
- }
277
- });
278
- if (!settled) {
279
- cancel = stream;
280
- cancels.add(cancel);
247
+ const settle = () => {
248
+ if (settled) return;
249
+ settled = true;
250
+ if (cancel) cancels.delete(cancel);
251
+ pendingWrites--;
252
+ maybeDone();
253
+ };
254
+ let stream;
255
+ try {
256
+ stream = serialize(key, value, {
257
+ onError: onError && (err => {
258
+ failed = true;
259
+ onError(err);
260
+ if (cancel) {
261
+ cancel();
262
+ settle();
263
+ }
264
+ }),
265
+ onDone: settle
266
+ }, initial => {
267
+ if (initial) started = true;
268
+ return !closed;
269
+ });
270
+ } catch (err) {
271
+ settle();
272
+ throw err;
273
+ }
274
+ if (settled) return;
275
+ if (closed || failed) {
276
+ stream();
277
+ settle();
278
+ return;
281
279
  }
280
+ cancel = stream;
281
+ cancels.add(cancel);
282
282
  },
283
283
  flush() {
284
284
  flushed = true;
285
285
  maybeDone();
286
286
  },
287
287
  close() {
288
- flushed = true;
288
+ closed = flushed = true;
289
289
  for (const cancel of cancels) cancel();
290
290
  cancels.clear();
291
+ if (!done) {
292
+ done = true;
293
+ onDone && onDone();
294
+ }
291
295
  }
292
296
  };
293
297
  }
298
+ function createJSONSerializer({
299
+ onData,
300
+ onDone,
301
+ onError,
302
+ plugins,
303
+ disabledFeatures,
304
+ depthLimit,
305
+ serializeErrorStacks
306
+ }) {
307
+ const resolved = resolveCodecOptions({
308
+ plugins,
309
+ disabledFeatures,
310
+ depthLimit,
311
+ serializeErrorStacks
312
+ });
313
+ const refs = new Map();
314
+ return createKeyedSerializer((key, value, callbacks, live) => toCrossJSONStream(value, {
315
+ refs,
316
+ plugins: resolved.plugins,
317
+ disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures(resolved.serializeErrorStacks),
318
+ onParse(node, initial) {
319
+ if (live(initial)) onData({
320
+ key,
321
+ node,
322
+ initial
323
+ });
324
+ },
325
+ ...callbacks
326
+ }), onError, onDone);
327
+ }
294
328
 
295
329
  const RECORDS = Symbol.for("@solidjs/signals/observe/records");
296
330
  function records() {
@@ -467,6 +501,7 @@ const stripHoleMarkers = html => html.replace(/<!--lh:\/?\d+-->/g, "");
467
501
  function frameSkeleton(html) {
468
502
  return html.replace(HOLE_RANGE, "<!--lh:$1--><!--lh:/$1-->").replace(SLOT_RANGE, "<!--slot:$1:start--><!--slot:$1:end-->");
469
503
  }
504
+ const ROW_HTML = Symbol.for("solid.rowHtml");
470
505
  function holeDigests(html, attrText, into = {}) {
471
506
  for (const m of html.matchAll(HOLE_RANGE)) {
472
507
  into["lh:" + m[1]] = textDigest(stripHoleMarkers(m[2]));
@@ -799,7 +834,7 @@ function createFrameSink(write, frame, have, hooks) {
799
834
  record.rows = rows;
800
835
  record.base = base;
801
836
  } else record.value = source;
802
- withHoles(record, holeDigests(record.rows ? rows.r.map(r => r[1]).join("") : source, null));
837
+ withHoles(record, holeDigests(record.rows ? (rows[ROW_HTML] || rows.r.map(r => r[1])).join("") : source, null));
803
838
  if (record.rows && hooks && hooks.retain) record[HOLE_SOURCE] = withHoles({
804
839
  kind: "html",
805
840
  value: source,