Skip to content

Commit 084e621

Browse files
fix(web): decide SSR text separators on resolved values (#3383) (#3394)
* fix(web): decide SSR text separators on resolved values (#3383) `resolveSSRNode` and `tryResolveString` emitted `<!--!$-->` between two adjacent array items whenever both had a non-object static type — which counted every function. Two neighbouring memos or components were separated as if they were text even when both produced elements, so a list of `Dynamic`, `Show`, or wrapper-library instances paid eight bytes and a comment node per item, and the client removed each one on hydrate. The client claims a multi-insert's nodes positionally after flattening its value, so what matters is what each item RESOLVES to: two texts must land in distinct text nodes; elements and template markup never need a separator. Track "last appended was text" through the walk (`ssrTextTail`, maintained at the leaves; arrays and functions pass it through; an unresolved async hole still counts as text on both sides) and reset it per independent region via the exported wrappers. Deciding on the resolved value also separates text the old rule merged: across a dropped nullish/boolean item (`[7, null, "x"]` → `7x`, one node) and across a nested array boundary (`["a", ["b"]]` → `ab`). Both were latent hydration mismatches — the second text item claimed nothing and materialized a client node on the first update. Parity harness: five scenarios covering the lists, the null gap, nested arrays, and mixed memo results, plus two invariants — `adoptAll` (every node is a server node after hydration AND after the update pass; a failed text claim is invisible to textContent until the update) and `noSeparators`. Against the previous walker, the server side emits separators for both element lists and the hydrate side reports `client-created text "x"` / `"b"` after update. Co-authored-by: Cursor <[email protected]> * test(web): type the memo-returning test components as JSX.Element test-types failed on next's Component type (SolidElement return): the #3383 fixtures return memos, valid children at runtime but not in the type. Cast at the three sites, JSX imported from @solidjs/web. Co-authored-by: Cursor <[email protected]> * test(web): re-record the separator-dynamic-element-list artifact after #3393 #3393 removed the trailing space before '>' on emitted tags; this scenario was recorded before it landed. Co-authored-by: Cursor <[email protected]> --------- Co-authored-by: Cursor <[email protected]>
1 parent 5b31076 commit 084e621

14 files changed

Lines changed: 340 additions & 25 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/web": patch
3+
---
4+
5+
SSR emits the `<!--!$-->` text separator only between items that resolve to text. Adjacent memos and components that yield elements — every `Dynamic`, `Show`, or wrapper-library instance in a list — no longer carry a separator and a comment node each. Text that becomes adjacent through a nested array or a dropped nullish item is now separated, so it hydrates into distinct text nodes (#3383).

‎packages/web/src/server.ts‎

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4448,22 +4448,46 @@ function flattenClassList(list, result) {
44484448
// whose backing component rebuilds an owner subtree on
44494449
// each access, producing a divergent hydration tree.
44504450
function tryResolveString(node) {
4451+
ssrTextTail = false;
4452+
return tryResolveStr(node);
4453+
}
4454+
4455+
// Text-hole separators. The client claims a multi-insert's nodes positionally
4456+
// after FLATTENING its value (memos resolved, nested arrays spliced, nullish
4457+
// dropped), so two consecutive items that both land as TEXT must arrive in
4458+
// distinct text nodes: `<!--!$-->` between them keeps the parser from merging
4459+
// them into one. Elements and template markup are nodes of their own and need
4460+
// no separator on either side. The decision is therefore made on the RESOLVED
4461+
// value, not the item's static type: a memo or component is a function here
4462+
// and may yield either, and separating every adjacent pair of functions cost
4463+
// eight bytes plus a comment node per component in a list (#3383).
4464+
//
4465+
// `ssrTextTail`: whether the last thing appended to the output of the region
4466+
// being walked was text. Leaves maintain it; arrays and functions pass it
4467+
// through (flattening semantics); an unresolved async hole counts as text on
4468+
// both sides since its content is unknown. Each independent region — a root
4469+
// resolve, a template hole, an element's children — starts fresh through the
4470+
// exported wrappers; only the internal walkers recurse.
4471+
let ssrTextTail = false;
4472+
4473+
function tryResolveStr(node) {
44514474
const t = typeof node;
4452-
if (t === "string") return node;
4453-
if (t === "number") return "" + node;
4475+
if (t === "string" || t === "number") {
4476+
const s = ssrTextTail ? "<!--!$-->" + node : "" + node;
4477+
ssrTextTail = true;
4478+
return s;
4479+
}
44544480
if (node == null || t === "boolean") return "";
44554481
if (t === "object") {
44564482
if (Array.isArray(node)) {
44574483
const joined = tryJoinPlainSSRArray(node);
4458-
if (joined !== undefined) return joined;
4484+
if (joined !== undefined) {
4485+
ssrTextTail = false;
4486+
return joined;
4487+
}
44594488
let s = "";
4460-
let prevNonObj = false;
44614489
for (let i = 0, len = node.length; i < len; i++) {
4462-
const item = node[i];
4463-
const itemNonObj = item !== null && typeof item !== "object";
4464-
if (prevNonObj && itemNonObj) s += "<!--!$-->";
4465-
prevNonObj = itemNonObj;
4466-
const r = tryResolveString(item);
4490+
const r = tryResolveStr(node[i]);
44674491
if (typeof r !== "string") return { bail: node };
44684492
s += r;
44694493
}
@@ -4476,19 +4500,22 @@ function tryResolveString(node) {
44764500
if ("_SOLID_DEV_") console.warn(`Unrecognized value. Skipped inserting`, node);
44774501
return "";
44784502
}
4503+
ssrTextTail = false;
44794504
return Array.isArray(node.t) ? node.t[0] : node.t;
44804505
}
44814506
if (t === "function") {
44824507
let v;
44834508
try {
44844509
v = node();
44854510
} catch (err) {
4486-
return buildAsyncWrap(err, node) || "";
4511+
const wrap = buildAsyncWrap(err, node);
4512+
if (wrap) ssrTextTail = true;
4513+
return wrap || "";
44874514
}
44884515
// Recurse on the evaluated value. If recursion bails, propagate the
44894516
// bail object unchanged — its `bail` field already carries the
44904517
// deepest evaluated form, so the caller never re-invokes `node`.
4491-
return tryResolveString(v);
4518+
return tryResolveStr(v);
44924519
}
44934520
return "";
44944521
}
@@ -4503,9 +4530,15 @@ export function resolveSSRNode(
45034530
},
45044531
top
45054532
) {
4533+
ssrTextTail = false;
4534+
return walkSSRNode(node, result, top);
4535+
}
4536+
4537+
function walkSSRNode(node, result, top) {
45064538
const t = typeof node;
45074539
if (t === "string" || t === "number") {
4508-
result.t[result.t.length - 1] += node;
4540+
result.t[result.t.length - 1] += ssrTextTail ? "<!--!$-->" + node : node;
4541+
ssrTextTail = true;
45094542
} else if (node == null || t === "boolean") {
45104543
} else if (Array.isArray(node)) {
45114544
// A `$slot`-tagged array is a slot RANGE reaching the walker as a plain
@@ -4516,13 +4549,11 @@ export function resolveSSRNode(
45164549
const slotLive = node.$slot && sharedConfig.context && sharedConfig.context.liveHoles;
45174550
if (slotLive) slotLive.suppressed++;
45184551
try {
4519-
let prevNonObj = false;
45204552
for (let i = 0, len = node.length; i < len; i++) {
4521-
const item = node[i];
4522-
const itemNonObj = item !== null && typeof item !== "object";
4523-
if (!top && prevNonObj && itemNonObj) result.t[result.t.length - 1] += `<!--!$-->`;
4524-
prevNonObj = itemNonObj;
4525-
resolveSSRNode(item, result);
4553+
// An element's direct children (`top`) are never separated from each
4554+
// other; separators still apply inside any nested array.
4555+
if (top) ssrTextTail = false;
4556+
walkSSRNode(node[i], result, false);
45264557
}
45274558
} finally {
45284559
if (slotLive) slotLive.suppressed--;
@@ -4535,8 +4566,10 @@ export function resolveSSRNode(
45354566
result.h.push(...node.h);
45364567
result.p.push(...node.p);
45374568
}
4569+
ssrTextTail = false;
45384570
} else if (node.t !== undefined) {
45394571
result.t[result.t.length - 1] += node.t;
4572+
ssrTextTail = false;
45404573
} else if ("_SOLID_DEV_") console.warn(`Unrecognized value. Skipped inserting`, node);
45414574
} else if (t === "function") {
45424575
// Function nodes reaching the tree resolver are content by construction
@@ -4548,17 +4581,23 @@ export function resolveSSRNode(
45484581
const live = sharedConfig.context && sharedConfig.context.liveHoles;
45494582
let liveNode = null;
45504583
if (live && (liveNode = live.content(node)) !== null) {
4551-
if (typeof liveNode === "string") result.t[result.t.length - 1] += liveNode;
4552-
else resolveSSRNode(liveNode, result);
4584+
if (typeof liveNode === "string") {
4585+
// Engine-rendered hole text: content of unknown shape, treated like
4586+
// an unresolved hole.
4587+
result.t[result.t.length - 1] += ssrTextTail ? "<!--!$-->" + liveNode : liveNode;
4588+
ssrTextTail = true;
4589+
} else walkSSRNode(liveNode, result, false);
45534590
} else {
45544591
try {
4555-
resolveSSRNode(node(), result);
4592+
walkSSRNode(node(), result, false);
45564593
} catch (err) {
45574594
const wrap = buildAsyncWrap(err, node);
45584595
if (wrap) {
4596+
if (ssrTextTail) result.t[result.t.length - 1] += "<!--!$-->";
45594597
result.h.push(wrap.fn);
45604598
result.p.push(wrap.p);
45614599
result.t.push("");
4600+
ssrTextTail = true;
45624601
}
45634602
}
45644603
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "client-only-before-suspending-fragment",
3-
"shell": "<!--!$--><template id=\"pl-2\"></template><i _hk=20>wait</i><!--pl-2--><script>(self.$R=self.$R||{})[\"\"]=[];_$HY.r[\"$B\"]=($R[0]={0:$R[1]=($R[2]=($R[3]=() => {\n\tconst resolver = {\n\t\tp: 0,\n\t\ts: 0,\n\t\tf: 0\n\t};\n\tresolver.p = new Promise((resolve, reject) => {\n\t\tresolver.s = resolve;\n\t\tresolver.f = reject;\n\t});\n\treturn resolver;\n})()).p,\"2_fr\":$R[4]=($R[5]=$R[3]()).p});(b=>{for(var k in b)_$HY.r[k]=b[k];delete _$HY.r[\"$B\"]})(_$HY.r[\"$B\"]);</script>",
3+
"shell": "<template id=\"pl-2\"></template><i _hk=20>wait</i><!--pl-2--><script>(self.$R=self.$R||{})[\"\"]=[];_$HY.r[\"$B\"]=($R[0]={0:$R[1]=($R[2]=($R[3]=() => {\n\tconst resolver = {\n\t\tp: 0,\n\t\ts: 0,\n\t\tf: 0\n\t};\n\tresolver.p = new Promise((resolve, reject) => {\n\t\tresolver.s = resolve;\n\t\tresolver.f = reject;\n\t});\n\treturn resolver;\n})()).p,\"2_fr\":$R[4]=($R[5]=$R[3]()).p});(b=>{for(var k in b)_$HY.r[k]=b[k];delete _$HY.r[\"$B\"]})(_$HY.r[\"$B\"]);</script>",
44
"rest": "<template id=\"2\"><p _hk=2000>loaded</p></template><script>($R[6]=(resolver, data) => {\n\tresolver.s(data);\n\tresolver.p.s = 1;\n\tresolver.p.v = data;\n})($R[2],\"loaded\");$df(\"2\");function $df(e){return _$HY.f?_$HY.f(e):$dfr(e)}function $dfr(e,n,o,t){if(!(n=document.getElementById(e)))return 0;if(!(o=document.getElementById(\"pl-\"+e)))return(_$HY.dq=_$HY.dq||{})[e]=1,0;for(;o&&(8!==o.nodeType||o.nodeValue!==\"pl-\"+e);)t=o.nextSibling,o.remove(),o=t;t=o.parentNode,o.replaceWith(n.content),n.remove(),(_$HY.v=_$HY.v||{})[e]=1,_$HY.fe(e,t),_$HY.hp&&_$HY.hp[e]&&($dh(_$HY.hp[e]),delete _$HY.hp[e]),$dfd();return 1}function $dfl(e,o,n){if(!(o=document.getElementById(\"pl-\"+e)))return(_$HY.dlq=_$HY.dlq||{})[e]=1,0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue===\"pl-\"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1,$dfd();return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfd(e,i){if(e=_$HY.dq){_$HY.dq=0;for(i in e)$df(i)}if(e=_$HY.dlq){_$HY.dlq=0;for(i in e)$dfl(i)}}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])};</script><script>$R[6]($R[5],!0);</script>"
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "client-only-before-suspending-route",
3-
"shell": "<!--!$--><template id=\"pl-1\"></template><i _hk=10>wait</i><!--pl-1--><script>(self.$R=self.$R||{})[\"\"]=[];_$HY.r[\"$B\"]=($R[0]={1000:$R[1]=($R[2]=($R[3]=() => {\n\tconst resolver = {\n\t\tp: 0,\n\t\ts: 0,\n\t\tf: 0\n\t};\n\tresolver.p = new Promise((resolve, reject) => {\n\t\tresolver.s = resolve;\n\t\tresolver.f = reject;\n\t});\n\treturn resolver;\n})()).p,\"1_fr\":$R[4]=($R[5]=$R[3]()).p});(b=>{for(var k in b)_$HY.r[k]=b[k];delete _$HY.r[\"$B\"]})(_$HY.r[\"$B\"]);</script>",
3+
"shell": "<template id=\"pl-1\"></template><i _hk=10>wait</i><!--pl-1--><script>(self.$R=self.$R||{})[\"\"]=[];_$HY.r[\"$B\"]=($R[0]={1000:$R[1]=($R[2]=($R[3]=() => {\n\tconst resolver = {\n\t\tp: 0,\n\t\ts: 0,\n\t\tf: 0\n\t};\n\tresolver.p = new Promise((resolve, reject) => {\n\t\tresolver.s = resolve;\n\t\tresolver.f = reject;\n\t});\n\treturn resolver;\n})()).p,\"1_fr\":$R[4]=($R[5]=$R[3]()).p});(b=>{for(var k in b)_$HY.r[k]=b[k];delete _$HY.r[\"$B\"]})(_$HY.r[\"$B\"]);</script>",
44
"rest": "<template id=\"1\"><p _hk=1001>loaded</p></template><script>($R[6]=(resolver, data) => {\n\tresolver.s(data);\n\tresolver.p.s = 1;\n\tresolver.p.v = data;\n})($R[2],\"loaded\");$df(\"1\");function $df(e){return _$HY.f?_$HY.f(e):$dfr(e)}function $dfr(e,n,o,t){if(!(n=document.getElementById(e)))return 0;if(!(o=document.getElementById(\"pl-\"+e)))return(_$HY.dq=_$HY.dq||{})[e]=1,0;for(;o&&(8!==o.nodeType||o.nodeValue!==\"pl-\"+e);)t=o.nextSibling,o.remove(),o=t;t=o.parentNode,o.replaceWith(n.content),n.remove(),(_$HY.v=_$HY.v||{})[e]=1,_$HY.fe(e,t),_$HY.hp&&_$HY.hp[e]&&($dh(_$HY.hp[e]),delete _$HY.hp[e]),$dfd();return 1}function $dfl(e,o,n){if(!(o=document.getElementById(\"pl-\"+e)))return(_$HY.dlq=_$HY.dlq||{})[e]=1,0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue===\"pl-\"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1,$dfd();return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfd(e,i){if(e=_$HY.dq){_$HY.dq=0;for(i in e)$df(i)}if(e=_$HY.dlq){_$HY.dlq=0;for(i in e)$dfl(i)}}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])};</script><script>$R[6]($R[5],!0);</script>"
55
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "separator-dynamic-element-list",
3+
"shell": "<ul _hk=0><li _hk=110>1</li><li _hk=130>2</li><li _hk=150>3</li></ul>",
4+
"rest": ""
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "separator-memo-element-list",
3+
"shell": "<ul _hk=0><li _hk=100><!--$-->1<!--/--><!--$-->.<!--/--></li><li _hk=110><!--$-->2<!--/--><!--$-->.<!--/--></li><li _hk=120><!--$-->3<!--/--><!--$-->.<!--/--></li><li _hk=130><!--$-->4<!--/--><!--$-->.<!--/--></li><li _hk=140><!--$-->5<!--/--><!--$-->.<!--/--></li></ul>",
4+
"rest": ""
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "separator-mixed-memo-results",
3+
"shell": "<div _hk=0>a<b _hk=110>1</b>c<!--!$-->d<i _hk=140>2</i>5</div>",
4+
"rest": ""
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "separator-nested-array-text",
3+
"shell": "<div _hk=1>a<!--!$-->b<i _hk=0>i</i>c<!--!$-->d</div>",
4+
"rest": ""
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "separator-text-after-null",
3+
"shell": "<div _hk=0>7<!--!$-->x</div>",
4+
"rest": ""
5+
}

‎packages/web/test/harness/scenarios.tsx‎

Lines changed: 137 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ import {
3434
Errored,
3535
Repeat
3636
} from "solid-js";
37-
import { Portal, httpStatus, httpHeader, clientOnly, isServer } from "@solidjs/web";
37+
import {
38+
Portal,
39+
Dynamic,
40+
httpStatus,
41+
httpHeader,
42+
clientOnly,
43+
isServer,
44+
type JSX
45+
} from "@solidjs/web";
3846

3947
const sleep = (ms: number) => new Promise(r => setTimeout(r, ms));
4048

@@ -73,6 +81,15 @@ export type Scenario = {
7381
* then late chunks — live streaming with $df swaps).
7482
*/
7583
async?: boolean;
84+
/**
85+
* Every node in the container after hydration must be a server node — no
86+
* client-created text or elements. Stronger than textContent, which reads
87+
* the same whether a text item adopted the server node or created its own
88+
* beside it (#3383).
89+
*/
90+
adoptAll?: boolean;
91+
/** the server-rendered HTML must contain no `<!--!$-->` text separators */
92+
noSeparators?: boolean;
7693
/** known-broken on main; hydrate spec wraps in test.fails */
7794
knownFailure?: string;
7895
/** known-broken only in the streamed replay mode */
@@ -1572,6 +1589,78 @@ function PropConditionForwarded() {
15721589
);
15731590
}
15741591

1592+
// ---------------------------------------------------------------------------
1593+
// Text separators (#3383). The server decides `<!--!$-->` on what each array
1594+
// item RESOLVES to; the client claims a flattened value positionally. These
1595+
// pin both directions: no separators (and no client-created nodes) for lists
1596+
// of element-yielding memos/components, and separators wherever two items
1597+
// land as adjacent text — including across a dropped nullish item or a
1598+
// nested array boundary, which the old static-type rule got wrong.
1599+
// Updates change text INSIDE the elements (a shared suffix signal) so the
1600+
// `<li>`s themselves must survive: the lists are `.map`, not `For`.
1601+
let setSepSuffix!: (v: string) => void;
1602+
function SepRow(props: { i: number; suffix: () => string }) {
1603+
// A memo is a valid child at runtime (resolved as a function child); the
1604+
// Component type only admits JSX.Element, hence the cast.
1605+
return createMemo(() => (
1606+
<li>
1607+
{props.i}
1608+
{props.suffix()}
1609+
</li>
1610+
)) as unknown as JSX.Element;
1611+
}
1612+
function MemoElementList() {
1613+
// Non-empty initially: an empty text hole hydrates to a client-created
1614+
// placeholder node, which is unrelated to what this scenario pins.
1615+
const [suffix, set] = createSignal(".");
1616+
setSepSuffix = set;
1617+
return (
1618+
<ul>
1619+
{[1, 2, 3, 4, 5].map(i => (
1620+
<SepRow i={i} suffix={suffix} />
1621+
))}
1622+
</ul>
1623+
);
1624+
}
1625+
1626+
let setSepDynSuffix!: (v: string) => void;
1627+
function DynamicElementList() {
1628+
const [suffix, set] = createSignal("");
1629+
setSepDynSuffix = set;
1630+
return (
1631+
<ul>
1632+
{[1, 2, 3].map(i => (
1633+
<Dynamic component="li">{`${i}${suffix()}`}</Dynamic>
1634+
))}
1635+
</ul>
1636+
);
1637+
}
1638+
1639+
let setSepCount!: (v: number) => void;
1640+
function TextAfterNull() {
1641+
const [count, set] = createSignal(7);
1642+
setSepCount = set;
1643+
const label = () => "x";
1644+
return <div>{[count(), null, label()]}</div>;
1645+
}
1646+
1647+
let setSepLabel!: (v: string) => void;
1648+
function NestedArrayText() {
1649+
const [label, set] = createSignal("c");
1650+
setSepLabel = set;
1651+
// Hoisted so the update re-evaluates the array without re-creating it.
1652+
const el = <i>i</i>;
1653+
return <div>{["a", ["b", el], label(), ["d"]]}</div>;
1654+
}
1655+
1656+
let setSepMixed!: (v: string) => void;
1657+
function MixedMemoResults() {
1658+
const [t, set] = createSignal("c");
1659+
setSepMixed = set;
1660+
const items = [() => "a", () => <b>1</b>, () => t(), () => "d", () => <i>2</i>, () => 5];
1661+
return <div>{items.map(f => createMemo(f))}</div>;
1662+
}
1663+
15751664
export const scenarios: Scenario[] = [
15761665
{
15771666
name: "text-hole",
@@ -2113,5 +2202,52 @@ export const scenarios: Scenario[] = [
21132202
update: () => setTeamId(undefined),
21142203
expectedTextAfterUpdate: "Some Team",
21152204
stableSelector: "main, div, h1"
2205+
},
2206+
{
2207+
name: "separator-memo-element-list",
2208+
App: MemoElementList,
2209+
expectedText: "1.2.3.4.5.",
2210+
adoptAll: true,
2211+
noSeparators: true,
2212+
update: () => setSepSuffix("!"),
2213+
expectedTextAfterUpdate: "1!2!3!4!5!",
2214+
stableSelector: "ul, li"
2215+
},
2216+
{
2217+
name: "separator-dynamic-element-list",
2218+
App: DynamicElementList,
2219+
expectedText: "123",
2220+
adoptAll: true,
2221+
noSeparators: true,
2222+
update: () => setSepDynSuffix("!"),
2223+
expectedTextAfterUpdate: "1!2!3!",
2224+
stableSelector: "ul, li"
2225+
},
2226+
{
2227+
name: "separator-text-after-null",
2228+
App: TextAfterNull,
2229+
expectedText: "7x",
2230+
adoptAll: true,
2231+
update: () => setSepCount(8),
2232+
expectedTextAfterUpdate: "8x",
2233+
stableSelector: "div"
2234+
},
2235+
{
2236+
name: "separator-nested-array-text",
2237+
App: NestedArrayText,
2238+
expectedText: "abicd",
2239+
adoptAll: true,
2240+
update: () => setSepLabel("C"),
2241+
expectedTextAfterUpdate: "abiCd",
2242+
stableSelector: "div, i"
2243+
},
2244+
{
2245+
name: "separator-mixed-memo-results",
2246+
App: MixedMemoResults,
2247+
expectedText: "a1cd25",
2248+
adoptAll: true,
2249+
update: () => setSepMixed("C"),
2250+
expectedTextAfterUpdate: "a1Cd25",
2251+
stableSelector: "div, b, i"
21162252
}
21172253
];

0 commit comments

Comments
 (0)