@barefootjs/jsx 0.37.0 → 0.38.0
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/adapters/env-signal.d.ts +0 -8
- package/dist/adapters/env-signal.d.ts.map +1 -1
- package/dist/adapters/interface.d.ts +12 -0
- package/dist/adapters/interface.d.ts.map +1 -1
- package/dist/analyzer.d.ts +40 -0
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/builtin-lowering-plugins.d.ts.map +1 -1
- package/dist/compiler.d.ts.map +1 -1
- package/dist/component-root-scope-comment.d.ts +36 -0
- package/dist/component-root-scope-comment.d.ts.map +1 -0
- package/dist/errors.d.ts +3 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/event-handler-name.d.ts +13 -0
- package/dist/event-handler-name.d.ts.map +1 -0
- package/dist/expression-parser.d.ts +9 -0
- package/dist/expression-parser.d.ts.map +1 -1
- package/dist/format-date-refusal.d.ts +37 -0
- package/dist/format-date-refusal.d.ts.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2973 -2310
- package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-branch-loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-component-loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-composite-loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts +13 -2
- package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-reactive-effects.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/lazy-conditional.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/lazy-row-eligibility.d.ts +1 -1
- package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts +9 -0
- package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/loop.d.ts +57 -12
- package/dist/ir-to-client-js/control-flow/plan/loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/shared.d.ts +44 -3
- package/dist/ir-to-client-js/control-flow/shared.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/component-loop.d.ts +7 -5
- package/dist/ir-to-client-js/control-flow/stringify/component-loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/loop-child-arm.d.ts +9 -1
- package/dist/ir-to-client-js/control-flow/stringify/loop-child-arm.d.ts.map +1 -1
- package/dist/ir-to-client-js/emit-reactive.d.ts +43 -2
- package/dist/ir-to-client-js/emit-reactive.d.ts.map +1 -1
- package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
- package/dist/ir-to-client-js/reactivity.d.ts +16 -1
- package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
- package/dist/ir-to-client-js/source-map.d.ts.map +1 -1
- package/dist/ir-to-client-js/types.d.ts +2 -0
- package/dist/ir-to-client-js/types.d.ts.map +1 -1
- package/dist/ir-to-client-js/utils.d.ts +26 -0
- package/dist/ir-to-client-js/utils.d.ts.map +1 -1
- package/dist/jsx-to-ir.d.ts.map +1 -1
- package/dist/opaque-local-accessor.d.ts +27 -0
- package/dist/opaque-local-accessor.d.ts.map +1 -0
- package/dist/to-locale-date-lowering.d.ts +7 -4
- package/dist/to-locale-date-lowering.d.ts.map +1 -1
- package/dist/types.d.ts +53 -17
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +724 -4564
- package/src/__tests__/binding-scope-ratchet.test.ts +21 -10
- package/src/__tests__/branch-local-in-raw-capture.test.ts +1 -1
- package/src/__tests__/branch-local-same-name-collision.test.ts +9 -9
- package/src/__tests__/client-js-generation.test.ts +175 -0
- package/src/__tests__/component-root-scope-comment.test.ts +106 -0
- package/src/__tests__/doc-examples.test.ts +12 -22
- package/src/__tests__/event-handler-name.test.ts +74 -0
- package/src/__tests__/flatmap-segments.test.ts +11 -9
- package/src/__tests__/format-date-refusal.test.ts +134 -0
- package/src/__tests__/fragment-wrapped-conditional-return-branch.test.ts +132 -0
- package/src/__tests__/hydrate-template.test.ts +9 -1
- package/src/__tests__/issue-2798-static-nested-loop-bindings.test.ts +2 -2
- package/src/__tests__/issue-3009-loop-branch-ref.test.ts +80 -0
- package/src/__tests__/issue-3044-nested-prop-object-array-not-static.test.ts +213 -0
- package/src/__tests__/issue-3113-init-fn-name-collision.test.ts +133 -0
- package/src/__tests__/jsx-return-type-assertion.test.ts +2 -2
- package/src/__tests__/lazy-row-eligibility.test.ts +5 -4
- package/src/__tests__/loop-row-child-children-reactive-attrs.test.ts +108 -0
- package/src/__tests__/loop-row-child-text-children-markers.test.ts +158 -0
- package/src/__tests__/opaque-local-accessor.test.ts +90 -0
- package/src/__tests__/profiler-e2e.test.ts +13 -8
- package/src/__tests__/ref-attr-absent-at-ssr.test.ts +472 -0
- package/src/__tests__/ssr-portal-ref-callback.test.ts +217 -0
- package/src/adapters/env-signal.ts +2 -21
- package/src/adapters/interface.ts +13 -0
- package/src/analyzer.ts +40 -28
- package/src/builtin-lowering-plugins.ts +0 -2
- package/src/compiler.ts +24 -0
- package/src/component-root-scope-comment.ts +59 -0
- package/src/errors.ts +44 -1
- package/src/event-handler-name.ts +14 -0
- package/src/expression-parser.ts +41 -17
- package/src/format-date-refusal.ts +266 -0
- package/src/index.ts +13 -3
- package/src/ir-to-client-js/child-components.ts +8 -3
- package/src/ir-to-client-js/collect-elements.ts +29 -13
- package/src/ir-to-client-js/control-flow/plan/build-branch-loop.ts +2 -4
- package/src/ir-to-client-js/control-flow/plan/build-component-loop.ts +67 -5
- package/src/ir-to-client-js/control-flow/plan/build-composite-loop.ts +3 -6
- package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +31 -1
- package/src/ir-to-client-js/control-flow/plan/build-loop.ts +23 -11
- package/src/ir-to-client-js/control-flow/plan/build-reactive-effects.ts +5 -0
- package/src/ir-to-client-js/control-flow/plan/lazy-conditional.ts +1 -0
- package/src/ir-to-client-js/control-flow/plan/lazy-row-eligibility.ts +3 -3
- package/src/ir-to-client-js/control-flow/plan/loop-child-arm.ts +11 -0
- package/src/ir-to-client-js/control-flow/plan/loop.ts +51 -10
- package/src/ir-to-client-js/control-flow/shared.ts +78 -5
- package/src/ir-to-client-js/control-flow/stringify/component-loop.ts +25 -12
- package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +22 -1
- package/src/ir-to-client-js/emit-reactive.ts +140 -10
- package/src/ir-to-client-js/emit-registration.ts +2 -2
- package/src/ir-to-client-js/generate-init.ts +2 -2
- package/src/ir-to-client-js/html-template.ts +41 -19
- package/src/ir-to-client-js/index.ts +4 -3
- package/src/ir-to-client-js/reactivity.ts +28 -17
- package/src/ir-to-client-js/source-map.ts +2 -1
- package/src/ir-to-client-js/types.ts +2 -0
- package/src/ir-to-client-js/utils.ts +34 -0
- package/src/jsx-to-ir.ts +737 -49
- package/src/opaque-local-accessor.ts +44 -0
- package/src/rich-type-refusal.ts +1 -1
- package/src/to-locale-date-lowering.ts +7 -4
- package/src/types.ts +51 -15
- package/dist/format-date-lowering.d.ts +0 -30
- package/dist/format-date-lowering.d.ts.map +0 -1
- package/src/__tests__/create-selector.test.ts +0 -124
- package/src/__tests__/format-date-lowering.test.ts +0 -125
- package/src/format-date-lowering.ts +0 -55
|
@@ -120,7 +120,7 @@ const ALLOWLIST: Record<string, Partial<Record<Pattern, number>>> = {
|
|
|
120
120
|
// for a follow-up rather than fixed speculatively here.
|
|
121
121
|
'packages/adapter-go-template/src/adapter/expr/helper-inline.ts': { 'localConstants.find(': 1 },
|
|
122
122
|
'packages/adapter-go-template/src/adapter/go-template-adapter.ts': {
|
|
123
|
-
// FLOOR: of the
|
|
123
|
+
// FLOOR: of the 6 `.find(` sites — `resolveDynamicPropValue` (child-prop
|
|
124
124
|
// passthrough, called only from `generateNewPropsFunction`'s
|
|
125
125
|
// `emitStaticChildInstances`), `computeDerivedConstFields` and
|
|
126
126
|
// `isStringExpr` (same `generateNewPropsFunction` constructor-context
|
|
@@ -132,17 +132,28 @@ const ALLOWLIST: Record<string, Partial<Record<Pattern, number>>> = {
|
|
|
132
132
|
// Stage 4 (a real gap: an enclosing loop's own item param could shadow
|
|
133
133
|
// a same-named module const and misfire a BF101) — MIGRATED in place,
|
|
134
134
|
// the `.find(` call itself stays as the legitimate lookup once shadow
|
|
135
|
-
// is ruled out.
|
|
136
|
-
|
|
135
|
+
// is ruled out. The 6th (#3164) is `resolveLoopArraySourceConst`'s own
|
|
136
|
+
// `.find(` — it REPLACES an ad-hoc `.find()` that `emitStaticBodyWrappers`
|
|
137
|
+
// used to inline directly (module-scope-only, and with no shadow guard
|
|
138
|
+
// at all), routing it through the same shape-1 shadow-name check as
|
|
139
|
+
// `getBakedStaticChildLoop` below instead — a consolidation onto the
|
|
140
|
+
// existing floor bucket, not a new unguarded use.
|
|
141
|
+
'localConstants.find(': 6,
|
|
137
142
|
// #2482 Stage 3: `loopParamStack` eliminated entirely (0, down from 35)
|
|
138
143
|
// — replaced by the threaded `this.scope: BindingScope`. The remaining
|
|
139
|
-
//
|
|
140
|
-
// `getBakedStaticChildLoop` shadow guard
|
|
141
|
-
//
|
|
142
|
-
//
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
|
|
144
|
+
// 3 `staticLoopSourceBoundNames` uses (down from 3, then #3164 added a
|
|
145
|
+
// third) are the `getBakedStaticChildLoop` shadow guard PLUS (#3164)
|
|
146
|
+
// `resolveLoopArraySourceConst`'s own guard, shared across call sites
|
|
147
|
+
// OUTSIDE the live `renderLoop` tree walk as well as inside it (no live
|
|
148
|
+
// `scope` to consult in the `emitStaticBodyWrappers` prepass — shape 1;
|
|
149
|
+
// reused as-is, rather than threaded, at the one live-walk call site
|
|
150
|
+
// for the same reason `getBakedStaticChildLoop` already is: the coarser
|
|
151
|
+
// whole-component check only ever over-excludes, never silently wrong,
|
|
152
|
+
// per this ledger's shape-1 rule) — a genuinely-legitimate surviving
|
|
153
|
+
// use, confirmed FLOOR in Stage 4 (`primeCompileState`'s own comment
|
|
154
|
+
// documents the three-call-site agreement requirement) and extended by
|
|
155
|
+
// one more call site in #3164.
|
|
156
|
+
staticLoopSourceBoundNames: 3,
|
|
146
157
|
},
|
|
147
158
|
// FLOOR (shape 1 for the field; the doc-only `loopParamStack` mention this
|
|
148
159
|
// file's top-level comment used to carry was reworded in Stage 4 — that
|
|
@@ -118,7 +118,7 @@ describe('branch-local references inside raw-captured JS (#1414 follow-ups)', ()
|
|
|
118
118
|
const [count] = createSignal(0)
|
|
119
119
|
if (props.kind === 'a') {
|
|
120
120
|
const label = 'highlighted'
|
|
121
|
-
return <div ref={(el) => { el.dataset.flag = label }}>A: {count()}</div>
|
|
121
|
+
return <div ref={(el) => { el.dataset.flag = label }} data-flag="highlighted">A: {count()}</div>
|
|
122
122
|
}
|
|
123
123
|
return <div>B: {count()}</div>
|
|
124
124
|
}
|
|
@@ -43,13 +43,13 @@ describe('same-name branch-local const referenced from nested function decl (#14
|
|
|
43
43
|
function attachA(el: HTMLElement) {
|
|
44
44
|
el.dataset.size = size
|
|
45
45
|
}
|
|
46
|
-
return <div ref={attachA}>A</div>
|
|
46
|
+
return <div ref={attachA} data-size="small">A</div>
|
|
47
47
|
}
|
|
48
48
|
const size = 'large'
|
|
49
49
|
function attachB(el: HTMLElement) {
|
|
50
50
|
el.dataset.size = size
|
|
51
51
|
}
|
|
52
|
-
return <div ref={attachB}>B</div>
|
|
52
|
+
return <div ref={attachB} data-size="large">B</div>
|
|
53
53
|
}
|
|
54
54
|
`
|
|
55
55
|
const result = compileJSX(source, 'TwoBranches.tsx', { adapter })
|
|
@@ -82,20 +82,20 @@ describe('same-name branch-local const referenced from nested function decl (#14
|
|
|
82
82
|
function attachA(el: HTMLElement) {
|
|
83
83
|
el.dataset.size = size
|
|
84
84
|
}
|
|
85
|
-
return <div ref={attachA}>A</div>
|
|
85
|
+
return <div ref={attachA} data-size="small">A</div>
|
|
86
86
|
}
|
|
87
87
|
if (props.mode === 'b') {
|
|
88
88
|
const size = 'medium'
|
|
89
89
|
function attachB(el: HTMLElement) {
|
|
90
90
|
el.dataset.size = size
|
|
91
91
|
}
|
|
92
|
-
return <div ref={attachB}>B</div>
|
|
92
|
+
return <div ref={attachB} data-size="medium">B</div>
|
|
93
93
|
}
|
|
94
94
|
const size = 'large'
|
|
95
95
|
function attachC(el: HTMLElement) {
|
|
96
96
|
el.dataset.size = size
|
|
97
97
|
}
|
|
98
|
-
return <div ref={attachC}>C</div>
|
|
98
|
+
return <div ref={attachC} data-size="large">C</div>
|
|
99
99
|
}
|
|
100
100
|
`
|
|
101
101
|
const result = compileJSX(source, 'ThreeBranches.tsx', { adapter })
|
|
@@ -129,20 +129,20 @@ describe('same-name branch-local const referenced from nested function decl (#14
|
|
|
129
129
|
function attachA(el: HTMLElement) {
|
|
130
130
|
el.dataset.value = String(value)
|
|
131
131
|
}
|
|
132
|
-
return <div ref={attachA}>A</div>
|
|
132
|
+
return <div ref={attachA} data-value="string-value">A</div>
|
|
133
133
|
}
|
|
134
134
|
if (props.mode === 'b') {
|
|
135
135
|
const value = 42
|
|
136
136
|
function attachB(el: HTMLElement) {
|
|
137
137
|
el.dataset.value = String(value)
|
|
138
138
|
}
|
|
139
|
-
return <div ref={attachB}>B</div>
|
|
139
|
+
return <div ref={attachB} data-value="42">B</div>
|
|
140
140
|
}
|
|
141
141
|
const value = true
|
|
142
142
|
function attachC(el: HTMLElement) {
|
|
143
143
|
el.dataset.value = String(value)
|
|
144
144
|
}
|
|
145
|
-
return <div ref={attachC}>C</div>
|
|
145
|
+
return <div ref={attachC} data-value="true">C</div>
|
|
146
146
|
}
|
|
147
147
|
`
|
|
148
148
|
const result = compileJSX(source, 'MixedKinds.tsx', { adapter })
|
|
@@ -244,7 +244,7 @@ describe('same-name branch-local const referenced from nested function decl (#14
|
|
|
244
244
|
function attach(el: HTMLElement) {
|
|
245
245
|
el.dataset.value = String(b)
|
|
246
246
|
}
|
|
247
|
-
return <div ref={attach}>A</div>
|
|
247
|
+
return <div ref={attach} data-value="2">A</div>
|
|
248
248
|
}
|
|
249
249
|
return <div>B</div>
|
|
250
250
|
}
|
|
@@ -1286,6 +1286,57 @@ describe('Client JS generation', () => {
|
|
|
1286
1286
|
expect(clientJs!.content).not.toContain("setAttribute('disabled'")
|
|
1287
1287
|
})
|
|
1288
1288
|
|
|
1289
|
+
// #3065 (accordion/radio-group): a boolean-IDL-named prop like `open`
|
|
1290
|
+
// is only a REAL property on the elements that natively expose it
|
|
1291
|
+
// (`<details>`, `<dialog>`) — most child components receiving it are
|
|
1292
|
+
// plain elements (a `<div>`, here) that merely happen to accept a
|
|
1293
|
+
// prop sharing that name for their OWN unrelated purposes. Before this
|
|
1294
|
+
// fix the mirror wrote `target.open = …` unconditionally (unlike the
|
|
1295
|
+
// `presenceOrUndefined`/generic branches, which already seed-gate on
|
|
1296
|
+
// `hasAttribute`), planting a live DOM property SSR never had and
|
|
1297
|
+
// that `captureDomState`'s STATE_PROPS check (`open` is one of the
|
|
1298
|
+
// properties it diffs) then saw appear only after hydration —
|
|
1299
|
+
// discovered via the accordion oracle once its OWN aria-expanded/
|
|
1300
|
+
// data-state divergence (the actual target of #3065) was fixed.
|
|
1301
|
+
test('mirrors a child component `open` prop gated on hasAttribute, not unconditionally (#3065)', () => {
|
|
1302
|
+
const source = `
|
|
1303
|
+
'use client'
|
|
1304
|
+
import { createSignal } from '@barefootjs/client'
|
|
1305
|
+
import { Section } from './Section'
|
|
1306
|
+
|
|
1307
|
+
export function Accordion() {
|
|
1308
|
+
const [expanded, setExpanded] = createSignal(false)
|
|
1309
|
+
return (
|
|
1310
|
+
<div>
|
|
1311
|
+
<Section open={expanded()} />
|
|
1312
|
+
</div>
|
|
1313
|
+
)
|
|
1314
|
+
}
|
|
1315
|
+
`
|
|
1316
|
+
|
|
1317
|
+
const result = compileJSX(source, 'Accordion.tsx', { adapter })
|
|
1318
|
+
expect(result.errors).toHaveLength(0)
|
|
1319
|
+
|
|
1320
|
+
const clientJs = result.files.find(f => f.type === 'clientJs')
|
|
1321
|
+
expect(clientJs).toBeDefined()
|
|
1322
|
+
expect(clientJs!.content).toContain(".hasAttribute('open')")
|
|
1323
|
+
expect(clientJs!.content).toContain('.open = !!')
|
|
1324
|
+
// A bare `open={signal()}` reaches BOTH the named-prop-binding mirror
|
|
1325
|
+
// (`emitReactivePropBindings`, ctx.reactiveProps) and the child-prop
|
|
1326
|
+
// mirror (`emitReactiveChildProps`, ctx.reactiveChildProps) for the
|
|
1327
|
+
// same slot — a regression in EITHER path's gate would still leave
|
|
1328
|
+
// the OTHER path's gated write in the output, so asserting presence
|
|
1329
|
+
// of a gated write alone can't catch one path regressing back to
|
|
1330
|
+
// unconditional. Each gated write is emitted on its own single line
|
|
1331
|
+
// (`emitAttrUpdate`'s mirrorSeed branch), so require every line that
|
|
1332
|
+
// writes `.open = !!` to also carry its `hasAttribute('open')` gate.
|
|
1333
|
+
const openWriteLines = clientJs!.content.split('\n').filter((line) => line.includes('.open = !!'))
|
|
1334
|
+
expect(openWriteLines.length).toBeGreaterThan(0)
|
|
1335
|
+
for (const line of openWriteLines) {
|
|
1336
|
+
expect(line).toContain("hasAttribute('open')")
|
|
1337
|
+
}
|
|
1338
|
+
})
|
|
1339
|
+
|
|
1289
1340
|
// #2716: a `value` prop passed to a CHILD COMPONENT (above) drives the
|
|
1290
1341
|
// no-SSR-fallback mirror path; a `value` ATTRIBUTE the developer writes
|
|
1291
1342
|
// directly on a plain HOST element is the opposite case — SSR renders
|
|
@@ -1314,6 +1365,68 @@ describe('Client JS generation', () => {
|
|
|
1314
1365
|
expect(clientJs!.content).toContain('.value =')
|
|
1315
1366
|
expect(clientJs!.content).toContain("setAttribute('value'")
|
|
1316
1367
|
})
|
|
1368
|
+
|
|
1369
|
+
// #3066: a controlled <select> whose value matches no <option> falls
|
|
1370
|
+
// back to selectedIndex 0 (the #2852 SSR placeholder) instead of
|
|
1371
|
+
// leaving the browser's own out-of-range resolution (selectedIndex -1)
|
|
1372
|
+
// as the live post-hydration state, which SSR never rendered.
|
|
1373
|
+
test('a controlled <select> value falls back to selectedIndex 0 on no match (#3066)', () => {
|
|
1374
|
+
const source = `
|
|
1375
|
+
'use client'
|
|
1376
|
+
import { createSignal } from '@barefootjs/client'
|
|
1377
|
+
|
|
1378
|
+
export function OutOfRangeSelect() {
|
|
1379
|
+
const [val] = createSignal(7)
|
|
1380
|
+
return (
|
|
1381
|
+
<select value={String(val())}>
|
|
1382
|
+
<option value="0">Zero</option>
|
|
1383
|
+
<option value="1">One</option>
|
|
1384
|
+
</select>
|
|
1385
|
+
)
|
|
1386
|
+
}
|
|
1387
|
+
`
|
|
1388
|
+
|
|
1389
|
+
const result = compileJSX(source, 'OutOfRangeSelect.tsx', { adapter })
|
|
1390
|
+
expect(result.errors).toHaveLength(0)
|
|
1391
|
+
|
|
1392
|
+
const clientJs = result.files.find(f => f.type === 'clientJs')
|
|
1393
|
+
expect(clientJs).toBeDefined()
|
|
1394
|
+
expect(clientJs!.content).toContain("tagName === 'SELECT'")
|
|
1395
|
+
expect(clientJs!.content).toContain('!')
|
|
1396
|
+
expect(clientJs!.content).toContain('.multiple')
|
|
1397
|
+
expect(clientJs!.content).toContain('.size <= 1')
|
|
1398
|
+
expect(clientJs!.content).toContain('.selectedIndex = 0')
|
|
1399
|
+
})
|
|
1400
|
+
|
|
1401
|
+
// A list box is `multiple` OR a `size` > 1 (`jsx-to-ir.ts`'s
|
|
1402
|
+
// `isMultiSelection`, which the SSR placeholder decision already keys
|
|
1403
|
+
// off) — checking `.multiple` alone here would force `selectedIndex =
|
|
1404
|
+
// 0` on a bare `size={2}` select whose SSR leg (correctly, per
|
|
1405
|
+
// `isMultiSelection`) left nothing selected on an out-of-range value,
|
|
1406
|
+
// reintroducing exactly the divergence #3066 fixed for `multiple`.
|
|
1407
|
+
test('does not force selectedIndex 0 on an out-of-range size>1 (list box) select (#3066)', () => {
|
|
1408
|
+
const source = `
|
|
1409
|
+
'use client'
|
|
1410
|
+
import { createSignal } from '@barefootjs/client'
|
|
1411
|
+
|
|
1412
|
+
export function OutOfRangeListBox() {
|
|
1413
|
+
const [val] = createSignal(7)
|
|
1414
|
+
return (
|
|
1415
|
+
<select size={2} value={String(val())}>
|
|
1416
|
+
<option value="0">Zero</option>
|
|
1417
|
+
<option value="1">One</option>
|
|
1418
|
+
</select>
|
|
1419
|
+
)
|
|
1420
|
+
}
|
|
1421
|
+
`
|
|
1422
|
+
|
|
1423
|
+
const result = compileJSX(source, 'OutOfRangeListBox.tsx', { adapter })
|
|
1424
|
+
expect(result.errors).toHaveLength(0)
|
|
1425
|
+
|
|
1426
|
+
const clientJs = result.files.find(f => f.type === 'clientJs')
|
|
1427
|
+
expect(clientJs).toBeDefined()
|
|
1428
|
+
expect(clientJs!.content).toContain('.size <= 1')
|
|
1429
|
+
})
|
|
1317
1430
|
})
|
|
1318
1431
|
|
|
1319
1432
|
describe('comment scope flag for fragment roots (#381)', () => {
|
|
@@ -2613,6 +2726,68 @@ describe('Client JS generation', () => {
|
|
|
2613
2726
|
// Should have initChild with props in the bindEvents callback
|
|
2614
2727
|
expect(content).toMatch(/initChild\('Alert'/)
|
|
2615
2728
|
})
|
|
2729
|
+
|
|
2730
|
+
test('a branch-owned child is initialized only by the branch, and still imported', () => {
|
|
2731
|
+
// The branch is active at hydration: `insert()`'s first run adopts
|
|
2732
|
+
// (or re-renders) it and its bindEvents inits the child. A second,
|
|
2733
|
+
// static `initChild` on the `$c` handle would init the same child a
|
|
2734
|
+
// second time — on a node the branch may already have replaced — so
|
|
2735
|
+
// its onMount/effects would run in two instances.
|
|
2736
|
+
const source = `
|
|
2737
|
+
'use client'
|
|
2738
|
+
import { createSignal } from '@barefootjs/client'
|
|
2739
|
+
import { Spinner } from './spinner'
|
|
2740
|
+
|
|
2741
|
+
export function Parent() {
|
|
2742
|
+
const [show, setShow] = createSignal(true)
|
|
2743
|
+
return (
|
|
2744
|
+
<div>
|
|
2745
|
+
<button onClick={() => setShow(!show())}>Toggle</button>
|
|
2746
|
+
{show() && <Spinner />}
|
|
2747
|
+
</div>
|
|
2748
|
+
)
|
|
2749
|
+
}
|
|
2750
|
+
`
|
|
2751
|
+
|
|
2752
|
+
const result = compileJSX(source, 'Parent.tsx', { adapter })
|
|
2753
|
+
expect(result.errors).toHaveLength(0)
|
|
2754
|
+
const content = result.files.find(f => f.type === 'clientJs')!.content
|
|
2755
|
+
|
|
2756
|
+
expect(content.match(/initChild\('Spinner'/g)).toHaveLength(1)
|
|
2757
|
+
expect(content).toMatch(/bindEvents:.*\n[\s\S]*?initChild\('Spinner'/)
|
|
2758
|
+
expect(content).not.toContain('$c(__scope')
|
|
2759
|
+
// The bundler still needs the child's module: the import marker is
|
|
2760
|
+
// collected from the branch, not from the (now absent) static init.
|
|
2761
|
+
expect(content).toContain("import '/* @bf-child:Spinner */'")
|
|
2762
|
+
})
|
|
2763
|
+
|
|
2764
|
+
test('a client-only branch-owned child is initialized only by the branch', () => {
|
|
2765
|
+
// Same ownership rule on the `/* @client */` path, which records its
|
|
2766
|
+
// conditional through `clientOnlyConditionals` instead.
|
|
2767
|
+
const source = `
|
|
2768
|
+
'use client'
|
|
2769
|
+
import { createSignal } from '@barefootjs/client'
|
|
2770
|
+
import { Spinner } from './spinner'
|
|
2771
|
+
|
|
2772
|
+
export function Parent() {
|
|
2773
|
+
const [show, setShow] = createSignal(true)
|
|
2774
|
+
return (
|
|
2775
|
+
<div>
|
|
2776
|
+
<button onClick={() => setShow(!show())}>Toggle</button>
|
|
2777
|
+
{/* @client */ show() && <Spinner />}
|
|
2778
|
+
</div>
|
|
2779
|
+
)
|
|
2780
|
+
}
|
|
2781
|
+
`
|
|
2782
|
+
|
|
2783
|
+
const result = compileJSX(source, 'Parent.tsx', { adapter })
|
|
2784
|
+
expect(result.errors).toHaveLength(0)
|
|
2785
|
+
const content = result.files.find(f => f.type === 'clientJs')!.content
|
|
2786
|
+
|
|
2787
|
+
expect(content.match(/initChild\('Spinner'/g)).toHaveLength(1)
|
|
2788
|
+
expect(content).not.toContain('$c(__scope')
|
|
2789
|
+
expect(content).toContain("import '/* @bf-child:Spinner */'")
|
|
2790
|
+
})
|
|
2616
2791
|
})
|
|
2617
2792
|
|
|
2618
2793
|
describe('reactive props.xxx detection (#789)', () => {
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `decideComponentRootScopeComment` (#3141) — the shared flag every
|
|
3
|
+
* adapter's `IRNodeEmitter.emitComponent` reads instead of re-deriving
|
|
4
|
+
* "is this component root client-interactive" locally.
|
|
5
|
+
*
|
|
6
|
+
* Runs through `compileJSX` — the SAME entry point `@barefootjs/vite`'s
|
|
7
|
+
* plugin and the CLI call in production (`packages/vite/src/plugin.ts`,
|
|
8
|
+
* `packages/cli/src/lib/preview/compile.ts`) — rather than calling
|
|
9
|
+
* `jsxToIR`/`buildMetadata` directly, with `outputIR: true` to inspect the
|
|
10
|
+
* exact `ComponentIR` the adapter itself renders from. This exercises the
|
|
11
|
+
* real ordering guarantee the fix depends on: `decideComponentRootScopeComment`
|
|
12
|
+
* must run AFTER `metadata.clientAnalysis` is computed and BEFORE
|
|
13
|
+
* `adapter.generate` reads `ir.root`, on the multi-component path
|
|
14
|
+
* (`compileMultipleComponents`) this fixture's two-component file — `Kid` +
|
|
15
|
+
* the exported root — takes, not the single-component one.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { describe, test, expect } from 'bun:test'
|
|
19
|
+
import { compileJSX } from '../compiler.ts'
|
|
20
|
+
import { TestAdapter } from '../adapters/test-adapter.ts'
|
|
21
|
+
import type { ComponentIR, IRComponent } from '../types.ts'
|
|
22
|
+
|
|
23
|
+
function irFor(source: string, filePath: string, componentName: string): ComponentIR {
|
|
24
|
+
const result = compileJSX(source, filePath, { adapter: new TestAdapter(), outputIR: true })
|
|
25
|
+
expect(result.errors).toEqual([])
|
|
26
|
+
const irFile = result.files.find(
|
|
27
|
+
(f) => f.type === 'ir' && f.path.includes(`.${componentName}.ir.json`),
|
|
28
|
+
) ?? result.files.find((f) => f.type === 'ir')
|
|
29
|
+
expect(irFile).toBeDefined()
|
|
30
|
+
return JSON.parse(irFile!.content) as ComponentIR
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
describe('decideComponentRootScopeComment', () => {
|
|
34
|
+
test('flags a client component whose root is a bare child-component call', () => {
|
|
35
|
+
const ir = irFor(
|
|
36
|
+
`
|
|
37
|
+
'use client'
|
|
38
|
+
import { createSignal } from '@barefootjs/client'
|
|
39
|
+
|
|
40
|
+
function Kid({ label, children }: { label: string; children?: unknown }) {
|
|
41
|
+
return (
|
|
42
|
+
<div>
|
|
43
|
+
<p>{label}</p>
|
|
44
|
+
{children}
|
|
45
|
+
</div>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function ComponentRootClientScope({ label }: { label: string }) {
|
|
50
|
+
const [text, setText] = createSignal(label)
|
|
51
|
+
return (
|
|
52
|
+
<Kid label={text()}>
|
|
53
|
+
<button onClick={() => setText('loaded')}>load</button>
|
|
54
|
+
</Kid>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
`,
|
|
58
|
+
'ComponentRootClientScope.tsx',
|
|
59
|
+
'ComponentRootClientScope',
|
|
60
|
+
)
|
|
61
|
+
expect(ir.root.type).toBe('component')
|
|
62
|
+
expect((ir.root as IRComponent).needsScopeComment).toBe(true)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
test('also flags a non-"use client" component whose root is a bare child-component call', () => {
|
|
66
|
+
// No `'use client'` directive and no signals here — but ANY nested
|
|
67
|
+
// component reference forces `clientAnalysis.needsInit` regardless
|
|
68
|
+
// (`childInits.length > 0` in `needsClientJs`, `ir-to-client-js/index.ts`):
|
|
69
|
+
// the parent always needs an init call to register/mount its child. So
|
|
70
|
+
// `hasClientInteractivity` (this function's formula, matching Hono's
|
|
71
|
+
// existing one) is true for EVERY `root.type === 'component'` shape,
|
|
72
|
+
// not only explicit `'use client'` ones — this pins that down rather
|
|
73
|
+
// than assuming the registry entry's `'use client'`-only `given` clause
|
|
74
|
+
// is the actual gate.
|
|
75
|
+
const ir = irFor(
|
|
76
|
+
`
|
|
77
|
+
function Kid({ label }: { label: string }) {
|
|
78
|
+
return <div>{label}</div>
|
|
79
|
+
}
|
|
80
|
+
export function StaticWrapper({ label }: { label: string }) {
|
|
81
|
+
return <Kid label={label} />
|
|
82
|
+
}
|
|
83
|
+
`,
|
|
84
|
+
'StaticWrapper.tsx',
|
|
85
|
+
'StaticWrapper',
|
|
86
|
+
)
|
|
87
|
+
expect(ir.root.type).toBe('component')
|
|
88
|
+
expect((ir.root as IRComponent).needsScopeComment).toBe(true)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
test('leaves a client component with a wrapping element root unflagged (nothing to change there)', () => {
|
|
92
|
+
const ir = irFor(
|
|
93
|
+
`
|
|
94
|
+
'use client'
|
|
95
|
+
import { createSignal } from '@barefootjs/client'
|
|
96
|
+
export function Wrapped({ label }: { label: string }) {
|
|
97
|
+
const [text] = createSignal(label)
|
|
98
|
+
return <div>{text()}</div>
|
|
99
|
+
}
|
|
100
|
+
`,
|
|
101
|
+
'Wrapped.tsx',
|
|
102
|
+
'Wrapped',
|
|
103
|
+
)
|
|
104
|
+
expect(ir.root.type).toBe('element')
|
|
105
|
+
})
|
|
106
|
+
})
|
|
@@ -283,48 +283,37 @@ const PAGES: PageSpec[] = [
|
|
|
283
283
|
return undefined
|
|
284
284
|
},
|
|
285
285
|
},
|
|
286
|
-
{ path: 'core/rendering/fragment.md' },
|
|
287
286
|
{ path: 'core/reactivity/create-signal.md' },
|
|
288
287
|
{ path: 'core/reactivity/create-effect.md' },
|
|
289
288
|
{ path: 'core/reactivity/create-memo.md' },
|
|
290
289
|
{ path: 'core/reactivity/on-mount.md' },
|
|
291
290
|
{ path: 'core/reactivity/on-cleanup.md' },
|
|
292
291
|
{ path: 'core/reactivity/untrack.md' },
|
|
292
|
+
{ path: 'core/reactivity/batch.md' },
|
|
293
293
|
{ path: 'core/reactivity/props-reactivity.md' },
|
|
294
|
-
{ path: 'core/components/component-authoring.
|
|
294
|
+
{ path: 'core/components/component-authoring.md' },
|
|
295
295
|
{ path: 'core/components/children-slots.md' },
|
|
296
|
-
{
|
|
296
|
+
{
|
|
297
|
+
path: 'core/components/context-api.md',
|
|
298
|
+
pageSkip: (body: string) => {
|
|
299
|
+
if (/\bapp\.get\b/.test(body)) return 'server route example (not a component)'
|
|
300
|
+
return undefined
|
|
301
|
+
},
|
|
302
|
+
},
|
|
297
303
|
{ path: 'core/components/portals.md' },
|
|
298
|
-
{ path: 'core/components/props-type-safety.md' },
|
|
299
304
|
{ path: 'core/components/styling.md' },
|
|
300
|
-
{ path: 'core/
|
|
301
|
-
{ path: 'core/
|
|
302
|
-
{ path: 'core/core-concepts/mpa-style.md' },
|
|
303
|
-
{ path: 'core/core-concepts/ai-native.md' },
|
|
305
|
+
{ path: 'core/how-it-works.mdx' },
|
|
306
|
+
{ path: 'core/advanced/testing-and-cli.md' },
|
|
304
307
|
{ path: 'core/adapters/hono-adapter.md' },
|
|
305
308
|
{ path: 'core/adapters/go-template-adapter.md' },
|
|
306
309
|
{ path: 'core/adapters/custom-adapter.md' },
|
|
307
|
-
// `core/advanced/code-splitting.md` is deliberately absent: it documents
|
|
308
|
-
// stock Vite/Rollup build config (`manualChunks`) and carries no
|
|
309
|
-
// component code, while this extractor only reads ```tsx fences. Adding
|
|
310
|
-
// a token component there purely to keep the page listed here would
|
|
311
|
-
// hollow out the check rather than extend it.
|
|
312
|
-
{ path: 'core/advanced/compiler-internals.md' },
|
|
313
310
|
// `core/advanced/error-codes.md` is handled by the per-BFxxx
|
|
314
311
|
// matcher (see bottom of file) rather than the general extractor:
|
|
315
312
|
// its `negative-all-adapters` strictness ("BFxxx must be the ONLY
|
|
316
313
|
// fatal") doesn't fit a reference page whose minimal reproductions
|
|
317
314
|
// routinely trip unrelated checks, and the per-section walker can
|
|
318
315
|
// tie each ❌ snippet to its parent `### BFxxx —` H3.
|
|
319
|
-
{ path: 'core/advanced/performance.md' },
|
|
320
316
|
{ path: 'core/reactivity.md' },
|
|
321
|
-
{
|
|
322
|
-
path: 'core/reactivity/shared-state.md',
|
|
323
|
-
pageSkip: (body: string) => {
|
|
324
|
-
if (/\bapp\.get\b/.test(body)) return 'server route example (not a component)'
|
|
325
|
-
return undefined
|
|
326
|
-
},
|
|
327
|
-
},
|
|
328
317
|
{ path: 'core/introduction.mdx' },
|
|
329
318
|
]
|
|
330
319
|
|
|
@@ -458,6 +447,7 @@ interface ErrorCodeContract {
|
|
|
458
447
|
const ERROR_CODES_DOC_TOO_MINIMAL: Record<string, string> = {
|
|
459
448
|
BF021: 'BF021 has multiple ❌ snippets in placeholder form (`.map(...)`) — covered concretely by `jsx-compatibility.md` tests; the doc-form snippets here remain placeholder',
|
|
460
449
|
BF044: 'BF044 fires only when a real signal getter is bound. The doc snippet `<Child count={count} />` references an undeclared `count`, so the check is silent — doc snippet needs enrichment',
|
|
450
|
+
BF102: 'BF102 is raised only by the Go adapter, from a boolean-test position its template grammar cannot host (an `else if` predicate, a module-scope helper in an `if` condition) — `TestAdapter` is JS-runtime-style and executes the condition verbatim, so the check is correctly silent here. Covered by the Go adapter\'s conformance pins (`module-helper-boolcontext-call`).',
|
|
461
451
|
BF101: 'BF101 is raised by the non-JS template adapters\' own per-adapter checks (Go/Mojo/Xslate/… `renderLoop` / callback lowering), not by the shared `isSupported` gate every adapter shares — `TestAdapter` here is JS-runtime-style like Hono and executes both doc snippets verbatim, so the check is correctly silent. Covered concretely (compiled against the real 8 template adapters, with verbatim diagnostic text) by `jsx-compatibility.md`\'s doc-examples coverage and the `filter-nested-callback-predicate` / `filter-nested-find-predicate` / `static-array-from-props` adapter-conformance fixtures.',
|
|
462
452
|
}
|
|
463
453
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `isEventHandlerName` is the one event-handler classification (`on[A-Z]`)
|
|
3
|
+
* shared by the IR builder, client-JS prop wiring and the SSR adapters. A
|
|
4
|
+
* prop merely starting with `on` (`only`, `once`) is data.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, test, expect } from 'bun:test'
|
|
7
|
+
import { analyzeComponent, buildMetadata, jsxToIR, isEventHandlerName } from '../index'
|
|
8
|
+
import { compileJSX } from '../compiler'
|
|
9
|
+
import { TestAdapter } from '../adapters/test-adapter'
|
|
10
|
+
import type { IRLoop, IRNode } from '../types'
|
|
11
|
+
|
|
12
|
+
describe('isEventHandlerName', () => {
|
|
13
|
+
test('on + uppercase letter is an event handler', () => {
|
|
14
|
+
for (const name of ['onClick', 'onValueChange', 'onX']) expect(isEventHandlerName(name)).toBe(true)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
test('names that merely start with `on` are data', () => {
|
|
18
|
+
for (const name of ['on', 'only', 'once', 'online', 'onclick', 'on-x', 'tone']) {
|
|
19
|
+
expect(isEventHandlerName(name)).toBe(false)
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test("a loop child component's `isEventHandler` flag uses it", () => {
|
|
24
|
+
const source = `
|
|
25
|
+
'use client'
|
|
26
|
+
function Mark(props: { once?: boolean; onPick?: () => void }) { return <em>x</em> }
|
|
27
|
+
export function Row() {
|
|
28
|
+
const items = [{ id: 'a', flag: true }]
|
|
29
|
+
return <ul>{items.map(o => <Mark key={o.id} once={o.flag} onPick={() => {}} />)}</ul>
|
|
30
|
+
}
|
|
31
|
+
`
|
|
32
|
+
const ctx = analyzeComponent(source, 'test.tsx', 'Row')
|
|
33
|
+
buildMetadata(ctx)
|
|
34
|
+
const root = jsxToIR(ctx)!
|
|
35
|
+
const findLoop = (n: IRNode): IRLoop | null => {
|
|
36
|
+
if (n.type === 'loop') return n as IRLoop
|
|
37
|
+
for (const c of (n as { children?: IRNode[] }).children ?? []) {
|
|
38
|
+
const hit = findLoop(c)
|
|
39
|
+
if (hit) return hit
|
|
40
|
+
}
|
|
41
|
+
return null
|
|
42
|
+
}
|
|
43
|
+
const props = findLoop(root)!.childComponent!.props
|
|
44
|
+
expect(props.find(p => p.name === 'once')!.isEventHandler).toBe(false)
|
|
45
|
+
expect(props.find(p => p.name === 'onPick')!.isEventHandler).toBe(true)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
// Client-JS consequence: a loop row's child component receives an
|
|
49
|
+
// `on`-prefixed DATA prop as a live getter like any other reactive prop,
|
|
50
|
+
// not as a one-shot value the way a handler is passed. `onPick` stays a
|
|
51
|
+
// plain handler entry.
|
|
52
|
+
test('a loop child component receives `only`/`once` as reactive getters, not handler values', () => {
|
|
53
|
+
const source = `
|
|
54
|
+
'use client'
|
|
55
|
+
import { createSignal } from '@barefootjs/client'
|
|
56
|
+
function Child(props: { only?: string; once?: boolean; onPick?: () => void }) {
|
|
57
|
+
return <span data-only={props.only}>c</span>
|
|
58
|
+
}
|
|
59
|
+
export function Rows() {
|
|
60
|
+
const [sel, setSel] = createSignal('a')
|
|
61
|
+
const [flag] = createSignal(false)
|
|
62
|
+
const items = [{ id: 'x' }, { id: 'y' }]
|
|
63
|
+
return <ul>{items.map(it => <li key={it.id}><Child only={sel()} once={flag()} onPick={() => setSel(it.id)} /></li>)}</ul>
|
|
64
|
+
}
|
|
65
|
+
`
|
|
66
|
+
const result = compileJSX(source, 'Rows.tsx', { adapter: new TestAdapter() })
|
|
67
|
+
expect(result.errors).toHaveLength(0)
|
|
68
|
+
const clientJs = result.files.find(f => f.type === 'clientJs')!.content
|
|
69
|
+
expect(clientJs).toContain('get only() { return sel() }')
|
|
70
|
+
expect(clientJs).toContain('get once() { return flag() }')
|
|
71
|
+
expect(clientJs).not.toContain('only: sel()')
|
|
72
|
+
expect(clientJs).toContain('onPick: () => setSel(it.id)')
|
|
73
|
+
})
|
|
74
|
+
})
|
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
* - TS type annotations in the block body are stripped from the client
|
|
9
9
|
* bundle (the old raw-slice carrier spliced them verbatim — invalid JS).
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
11
|
+
* The leaf `data-key` rides BOTH renders of a flatMap leaf: the CSR string
|
|
12
|
+
* template (`h:` descriptor HTML, `escapeAttr`-wrapped) and the Hono rawBody
|
|
13
|
+
* SSR (the leaf's `key` attribute is rewritten to `data-key={String(key)}`
|
|
14
|
+
* in the branded source text). Hydration therefore finds the attribute
|
|
15
|
+
* already in place instead of adding it, which is what the browser oracle
|
|
16
|
+
* (`tag-cloud` fixture) pins. Slot comment markers inside flatMap leaves
|
|
17
|
+
* remain client-side only.
|
|
17
18
|
*/
|
|
18
19
|
|
|
19
20
|
import { describe, test, expect } from 'bun:test'
|
|
@@ -165,7 +166,7 @@ export function F() {
|
|
|
165
166
|
const cj = r.files.find(f => f.type === 'clientJs')!.content
|
|
166
167
|
// Flattened source with descriptor leaves…
|
|
167
168
|
expect(cj).toMatch(/mapArray\(\(\) => \(todos\(\)\)\.flatMap\(\(t\) => \{/)
|
|
168
|
-
expect(cj).toMatch(/\(\{ k: \(`\$\{t\.id\}:\$\{tag\}`\), h: `<li>/)
|
|
169
|
+
expect(cj).toMatch(/\(\{ k: \(`\$\{t\.id\}:\$\{tag\}`\), h: `<li data-key="\$\{escapeAttr\(String\(\(`\$\{t\.id\}:\$\{tag\}`\)\)\)\}">/)
|
|
169
170
|
// …keyed on the leaf key with index fallback…
|
|
170
171
|
expect(cj).toMatch(/\(__bfD, __bfI\) => String\(__bfD\.k \?\? __bfI\)/)
|
|
171
172
|
// …renderItem builds from the descriptor HTML and patches on change…
|
|
@@ -174,8 +175,9 @@ export function F() {
|
|
|
174
175
|
// …and the statements-before-return are NOT duplicated as a renderItem
|
|
175
176
|
// preamble (the segments carrier is the single door).
|
|
176
177
|
expect(cj).not.toMatch(/return \[\];* if \(__existing\)/)
|
|
177
|
-
//
|
|
178
|
-
|
|
178
|
+
// The leaf key is rendered as an escaped `data-key` in the descriptor HTML
|
|
179
|
+
// (SSR emits the same attribute, so hydration never has to add it).
|
|
180
|
+
expect(cj).toMatch(/data-key="\$\{escapeAttr\(/)
|
|
179
181
|
})
|
|
180
182
|
|
|
181
183
|
test('a leaf with an event handler refuses loudly (no silent dead DOM)', () => {
|