@barefootjs/jsx 0.40.1 → 0.41.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/boolean-result.d.ts +32 -10
- package/dist/adapters/boolean-result.d.ts.map +1 -1
- package/dist/adapters/brace-delimiter-text.d.ts +18 -0
- package/dist/adapters/brace-delimiter-text.d.ts.map +1 -0
- package/dist/adapters/callback-method.d.ts +45 -5
- package/dist/adapters/callback-method.d.ts.map +1 -1
- package/dist/adapters/component-props.d.ts +3 -4
- package/dist/adapters/component-props.d.ts.map +1 -1
- package/dist/adapters/computed-const.d.ts +11 -1
- package/dist/adapters/computed-const.d.ts.map +1 -1
- package/dist/adapters/dsl-template-adapter.d.ts +24 -12
- package/dist/adapters/dsl-template-adapter.d.ts.map +1 -1
- package/dist/adapters/loop-bound-names.d.ts +9 -1
- package/dist/adapters/loop-bound-names.d.ts.map +1 -1
- package/dist/adapters/loop-row-type.d.ts +59 -0
- package/dist/adapters/loop-row-type.d.ts.map +1 -0
- package/dist/adapters/nil-reading.d.ts +63 -0
- package/dist/adapters/nil-reading.d.ts.map +1 -0
- package/dist/adapters/non-primitive-equality.d.ts +33 -0
- package/dist/adapters/non-primitive-equality.d.ts.map +1 -0
- package/dist/adapters/number-value.d.ts +5 -3
- package/dist/adapters/number-value.d.ts.map +1 -1
- package/dist/adapters/operand-typing.d.ts +126 -0
- package/dist/adapters/operand-typing.d.ts.map +1 -0
- package/dist/adapters/parsed-expr-emitter.d.ts +80 -12
- package/dist/adapters/parsed-expr-emitter.d.ts.map +1 -1
- package/dist/adapters/primitive-plan.d.ts +320 -0
- package/dist/adapters/primitive-plan.d.ts.map +1 -0
- package/dist/adapters/prop-classes.d.ts +5 -0
- package/dist/adapters/prop-classes.d.ts.map +1 -1
- package/dist/analyzer-context.d.ts +4 -0
- package/dist/analyzer-context.d.ts.map +1 -1
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/augment-inherited-props.d.ts +63 -8
- package/dist/augment-inherited-props.d.ts.map +1 -1
- package/dist/compiler.d.ts.map +1 -1
- package/dist/event-handler-name.d.ts +12 -0
- package/dist/event-handler-name.d.ts.map +1 -1
- package/dist/expression-parser.d.ts +8 -0
- package/dist/expression-parser.d.ts.map +1 -1
- package/dist/index.d.ts +20 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4903 -2311
- package/dist/ir-to-client-js/build-references.d.ts.map +1 -1
- package/dist/ir-to-client-js/child-props-object.d.ts +106 -0
- package/dist/ir-to-client-js/child-props-object.d.ts.map +1 -0
- package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts.map +1 -1
- 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/shared.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts +4 -2
- package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts.map +1 -1
- package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
- package/dist/ir-to-client-js/imports.d.ts +2 -2
- package/dist/ir-to-client-js/imports.d.ts.map +1 -1
- package/dist/ir-to-client-js/index.d.ts +2 -6
- package/dist/ir-to-client-js/index.d.ts.map +1 -1
- package/dist/ir-to-client-js/phases/props-extraction.d.ts +3 -3
- package/dist/ir-to-client-js/plan/build-declaration-emit.d.ts.map +1 -1
- package/dist/ir-to-client-js/plan/build-static-array-child-init.d.ts.map +1 -1
- package/dist/ir-to-client-js/plan/static-array-child-init.d.ts +30 -18
- package/dist/ir-to-client-js/plan/static-array-child-init.d.ts.map +1 -1
- package/dist/ir-to-client-js/prop-handling.d.ts.map +1 -1
- package/dist/ir-to-client-js/prune-unused-prop-extractions.d.ts +3 -1
- package/dist/ir-to-client-js/prune-unused-prop-extractions.d.ts.map +1 -1
- package/dist/ir-to-client-js/stringify/static-array-child-init.d.ts +3 -2
- package/dist/ir-to-client-js/stringify/static-array-child-init.d.ts.map +1 -1
- package/dist/jsx-to-ir.d.ts +1 -0
- package/dist/jsx-to-ir.d.ts.map +1 -1
- package/dist/nullable-signal-attr.d.ts +51 -34
- package/dist/nullable-signal-attr.d.ts.map +1 -1
- package/dist/prop-rewrite.d.ts +7 -0
- package/dist/prop-rewrite.d.ts.map +1 -1
- package/dist/props-binding.d.ts +58 -13
- package/dist/props-binding.d.ts.map +1 -1
- package/dist/props-object-whole-read.d.ts +15 -0
- package/dist/props-object-whole-read.d.ts.map +1 -0
- package/dist/rich-type-refusal.d.ts.map +1 -1
- package/dist/scope/binding-scope.d.ts +85 -10
- package/dist/scope/binding-scope.d.ts.map +1 -1
- package/dist/scope/lexical-scope-walk.d.ts +3 -2
- package/dist/scope/lexical-scope-walk.d.ts.map +1 -1
- package/dist/scope/root-prop-alias.d.ts +10 -7
- package/dist/scope/root-prop-alias.d.ts.map +1 -1
- package/dist/ssr-defaults.d.ts +39 -3
- package/dist/ssr-defaults.d.ts.map +1 -1
- package/dist/strip-types.d.ts +13 -0
- package/dist/strip-types.d.ts.map +1 -1
- package/dist/template-position-walk.d.ts +21 -3
- package/dist/template-position-walk.d.ts.map +1 -1
- package/dist/types.d.ts +90 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +9 -9
- package/src/__tests__/binding-scope.test.ts +89 -1
- package/src/__tests__/body-destructure-props-object-alias.test.ts +123 -0
- package/src/__tests__/body-destructured-prop-default-arrow.test.ts +2 -2
- package/src/__tests__/body-destructured-props-live.test.ts +5 -5
- package/src/__tests__/boolean-result.test.ts +22 -5
- package/src/__tests__/brace-delimiter-text.test.ts +26 -0
- package/src/__tests__/callback-method.test.ts +62 -2
- package/src/__tests__/child-components-in-map.test.ts +1 -1
- package/src/__tests__/client-js-generation.test.ts +3 -3
- package/src/__tests__/computed-const.test.ts +103 -0
- package/src/__tests__/destructure-default-reads-earlier-param.test.ts +7 -7
- package/src/__tests__/destructured-props-live.test.ts +1 -1
- package/src/__tests__/emit-to-string-call.test.ts +2 -1
- package/src/__tests__/hydration-payload-analysis.test.ts +166 -0
- package/src/__tests__/issue-2724-prop-alias-loop-not-static.test.ts +7 -7
- package/src/__tests__/issue-2754-rest-spread-needs-slot.test.ts +5 -2
- package/src/__tests__/issue-2798-static-nested-loop-bindings.test.ts +1 -1
- package/src/__tests__/issue-2835-props-type-member-name-collision.test.ts +4 -4
- package/src/__tests__/issue-3044-nested-prop-object-array-not-static.test.ts +1 -1
- package/src/__tests__/issue-3688-props-spread-child-csr.test.ts +2 -1
- package/src/__tests__/issue-3713-props-spread-loop-row.test.ts +65 -0
- package/src/__tests__/issue-3861-object-spread-child.test.ts +102 -0
- package/src/__tests__/lookup-literal-const.test.ts +9 -3
- package/src/__tests__/loop-index-reactivity.test.ts +2 -2
- package/src/__tests__/loop-param-accessor-key-member-safety.test.ts +1 -1
- package/src/__tests__/loop-plan.test.ts +1 -1
- package/src/__tests__/loop-row-const-initializer-shadow.test.ts +146 -0
- package/src/__tests__/loop-row-type.test.ts +64 -0
- package/src/__tests__/lowering-value-position.test.ts +4 -0
- package/src/__tests__/memo-body-expr.test.ts +2 -2
- package/src/__tests__/module-const-destructure-default.test.ts +156 -0
- package/src/__tests__/nested-loop-index-param.test.ts +1 -1
- package/src/__tests__/nested-loop-reactive-attrs.test.ts +2 -2
- package/src/__tests__/nested-row-shadowing.test.ts +2 -2
- package/src/__tests__/nil-reading.test.ts +78 -0
- package/src/__tests__/nullable-signal-attr.test.ts +109 -48
- package/src/__tests__/primitive-plan.test.ts +494 -0
- package/src/__tests__/profile-loop-binding-ids.test.ts +2 -2
- package/src/__tests__/profile-nested-binding-ids.test.ts +2 -2
- package/src/__tests__/prop-default-undefined-only.test.ts +115 -0
- package/src/__tests__/prop-references.test.ts +2 -2
- package/src/__tests__/props-destructuring.test.ts +17 -0
- package/src/__tests__/props-object-whole-read.test.ts +40 -0
- package/src/__tests__/prune-unused-prop-extractions.test.ts +3 -3
- package/src/__tests__/reactive-attrs-in-map.test.ts +1 -1
- package/src/__tests__/reactive-factory-inlining.test.ts +4 -1
- package/src/__tests__/renamed-body-destructure-template.test.ts +7 -7
- package/src/__tests__/rest-binding-gaps.test.ts +192 -0
- package/src/__tests__/rewrite-destructured-props.test.ts +1 -1
- package/src/__tests__/root-prop-alias.test.ts +53 -8
- package/src/__tests__/ssr-defaults.test.ts +113 -25
- package/src/__tests__/static-loop-csr-materialize.test.ts +2 -2
- package/src/__tests__/static-record-literal-array.test.ts +171 -0
- package/src/__tests__/string-concat-identifier.test.ts +40 -1
- package/src/__tests__/written-binding-substitution.test.ts +8 -8
- package/src/adapters/boolean-result.ts +72 -66
- package/src/adapters/brace-delimiter-text.ts +25 -0
- package/src/adapters/callback-method.ts +159 -27
- package/src/adapters/component-props.ts +3 -4
- package/src/adapters/computed-const.ts +238 -4
- package/src/adapters/dsl-template-adapter.ts +62 -26
- package/src/adapters/loop-bound-names.ts +9 -1
- package/src/adapters/loop-plan.ts +1 -1
- package/src/adapters/loop-row-type.ts +149 -0
- package/src/adapters/nil-reading.ts +295 -0
- package/src/adapters/non-primitive-equality.ts +92 -0
- package/src/adapters/number-value.ts +17 -4
- package/src/adapters/operand-typing.ts +522 -0
- package/src/adapters/parsed-expr-emitter.ts +183 -19
- package/src/adapters/primitive-plan.ts +765 -0
- package/src/adapters/prop-classes.ts +16 -3
- package/src/analyzer-context.ts +6 -0
- package/src/analyzer.ts +532 -26
- package/src/augment-inherited-props.ts +108 -10
- package/src/compiler.ts +17 -0
- package/src/event-handler-name.ts +15 -0
- package/src/expression-parser.ts +70 -1
- package/src/index.ts +35 -16
- package/src/ir-to-client-js/build-references.ts +69 -0
- package/src/ir-to-client-js/child-props-object.ts +240 -0
- package/src/ir-to-client-js/collect-elements.ts +31 -63
- package/src/ir-to-client-js/control-flow/plan/build-inner-loop.ts +8 -1
- package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +31 -28
- package/src/ir-to-client-js/control-flow/shared.ts +20 -22
- package/src/ir-to-client-js/control-flow/stringify/claim-plan.ts +5 -3
- package/src/ir-to-client-js/control-flow/stringify/inner-loop.ts +2 -2
- package/src/ir-to-client-js/control-flow/stringify/lazy-row.ts +1 -1
- package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +2 -2
- package/src/ir-to-client-js/control-flow/stringify/loop.ts +1 -1
- package/src/ir-to-client-js/control-flow/stringify/reactive-effects.ts +3 -3
- package/src/ir-to-client-js/html-template.ts +43 -17
- package/src/ir-to-client-js/imports.ts +2 -2
- package/src/ir-to-client-js/index.ts +53 -11
- package/src/ir-to-client-js/phases/props-extraction.ts +11 -7
- package/src/ir-to-client-js/plan/build-declaration-emit.ts +40 -7
- package/src/ir-to-client-js/plan/build-static-array-child-init.ts +31 -14
- package/src/ir-to-client-js/plan/static-array-child-init.ts +27 -18
- package/src/ir-to-client-js/prop-handling.ts +22 -3
- package/src/ir-to-client-js/prune-unused-prop-extractions.ts +58 -5
- package/src/ir-to-client-js/rewrite-destructured-props.ts +31 -1
- package/src/ir-to-client-js/stringify/static-array-child-init.ts +26 -10
- package/src/jsx-to-ir.ts +459 -37
- package/src/nullable-signal-attr.ts +200 -110
- package/src/prop-rewrite.ts +30 -6
- package/src/props-binding.ts +84 -19
- package/src/props-object-whole-read.ts +87 -0
- package/src/rich-type-refusal.ts +2 -1
- package/src/scope/binding-scope.ts +182 -18
- package/src/scope/lexical-scope-walk.ts +4 -3
- package/src/scope/root-prop-alias.ts +15 -8
- package/src/ssr-defaults.ts +100 -11
- package/src/strip-types.ts +31 -3
- package/src/template-position-walk.ts +57 -28
- package/src/types.ts +87 -0
- package/dist/adapters/ambiguous-nil-arithmetic.d.ts +0 -41
- package/dist/adapters/ambiguous-nil-arithmetic.d.ts.map +0 -1
- package/src/adapters/ambiguous-nil-arithmetic.ts +0 -94
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the client reads beyond its named props, decided before the adapter
|
|
3
|
+
* runs (#3845): a destructured prop read only in a `.filter()` predicate
|
|
4
|
+
* reaches the module-scope client template as `_p.<key>`, a closed-type rest
|
|
5
|
+
* key the client reads is in `clientAnalysis.usedRestKeys`, and a spread of
|
|
6
|
+
* a whole caller bag sets `clientAnalysis.readsCallerBag`.
|
|
7
|
+
*
|
|
8
|
+
* The rendered shapes are conformance fixtures (`filter-predicate-on-prefixed-prop`,
|
|
9
|
+
* `rest-spread-root-hydration-props`, …). These pin the name-binding edges
|
|
10
|
+
* the fixtures do not reach: a filter parameter or a loop row named like the
|
|
11
|
+
* prop or the bag.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { describe, test, expect } from 'bun:test'
|
|
15
|
+
import { compileJSX } from '../compiler'
|
|
16
|
+
import { TestAdapter } from '../adapters/test-adapter'
|
|
17
|
+
import { isHydrationPayloadPropName } from '../event-handler-name'
|
|
18
|
+
import type { ComponentIR } from '../types'
|
|
19
|
+
|
|
20
|
+
const adapter = new TestAdapter()
|
|
21
|
+
|
|
22
|
+
function compile(source: string): { js: string; ir: ComponentIR } {
|
|
23
|
+
const result = compileJSX(source, 'C.tsx', { adapter, outputIR: true })
|
|
24
|
+
expect(result.errors.filter(e => e.severity === 'error')).toHaveLength(0)
|
|
25
|
+
const js = result.files.find(f => f.type === 'clientJs')!.content
|
|
26
|
+
const irs = result.files.filter(f => f.type === 'ir').map(f => JSON.parse(f.content) as ComponentIR)
|
|
27
|
+
const ir = irs.find(c => c.metadata.componentName === 'C')!
|
|
28
|
+
return { js, ir }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The `template: (_p) => …` lambda the client registers for `C`. */
|
|
32
|
+
function templateLine(js: string): string {
|
|
33
|
+
const line = js.split('\n').find(l => l.includes("hydrate('C'") && l.includes('template: (_p) =>'))
|
|
34
|
+
expect(line).toBeDefined()
|
|
35
|
+
return line!
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Everything the client registers for `C`, including a multi-line template. */
|
|
39
|
+
function templateSource(js: string): string {
|
|
40
|
+
const start = js.indexOf("hydrate('C'")
|
|
41
|
+
expect(start).toBeGreaterThanOrEqual(0)
|
|
42
|
+
return js.slice(start)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
describe('filter predicate in the client template (#3845)', () => {
|
|
46
|
+
test('a destructured prop read in the predicate becomes `_p.<key>`', () => {
|
|
47
|
+
const { js } = compile(`
|
|
48
|
+
'use client'
|
|
49
|
+
export function C({ keys, one }: { keys: string[]; one: string }) {
|
|
50
|
+
return <ul>{keys.filter(k => k === one).map(k => <li key={k}>{k}</li>)}</ul>
|
|
51
|
+
}
|
|
52
|
+
`)
|
|
53
|
+
expect(templateLine(js)).toContain('.filter(k => k === _p.one)')
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test('the predicate parameter keeps its name when a prop shares it', () => {
|
|
57
|
+
const { js } = compile(`
|
|
58
|
+
'use client'
|
|
59
|
+
export function C({ keys, k }: { keys: string[]; k: string }) {
|
|
60
|
+
return <div data-k={k}><ul>{keys.filter(k => k !== '').map(v => <li key={v}>{v}</li>)}</ul></div>
|
|
61
|
+
}
|
|
62
|
+
`)
|
|
63
|
+
expect(templateLine(js)).toContain(".filter(k => k !== '')")
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
test('an enclosing row binding named like the prop keeps its name', () => {
|
|
67
|
+
const { js } = compile(`
|
|
68
|
+
'use client'
|
|
69
|
+
export function C({ groups, one }: { groups: { one: string; keys: string[] }[]; one: string }) {
|
|
70
|
+
return (
|
|
71
|
+
<div data-one={one}>
|
|
72
|
+
{groups.map(({ one, keys }) => (
|
|
73
|
+
<ul key={one}>{keys.filter(k => k === one).map(k => <li key={k}>{k}</li>)}</ul>
|
|
74
|
+
))}
|
|
75
|
+
</div>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
`)
|
|
79
|
+
const line = templateLine(js)
|
|
80
|
+
expect(line).toContain('.filter(k => k === one)')
|
|
81
|
+
expect(line).not.toContain('k === _p.one')
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
test('a block body rewrites the outer read and keeps an inner `const` of the same name', () => {
|
|
85
|
+
const { js } = compile(`
|
|
86
|
+
'use client'
|
|
87
|
+
export function C({ keys, one }: { keys: string[]; one: string }) {
|
|
88
|
+
return <ul>{keys.filter(k => {
|
|
89
|
+
const v = one
|
|
90
|
+
if (k === 'a') {
|
|
91
|
+
const one = 'a'
|
|
92
|
+
return k === one
|
|
93
|
+
}
|
|
94
|
+
return k === v
|
|
95
|
+
}).map(k => <li key={k}>{k}</li>)}</ul>
|
|
96
|
+
}
|
|
97
|
+
`)
|
|
98
|
+
const tpl = templateSource(js)
|
|
99
|
+
expect(tpl).toContain('const v = _p.one')
|
|
100
|
+
expect(tpl).toContain("const one = 'a'")
|
|
101
|
+
expect(tpl).toContain('return k === one')
|
|
102
|
+
expect(tpl).not.toContain('const _p.one')
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
test('a block body keeps a nested-block `var` hoisted over the whole body', () => {
|
|
106
|
+
const { js } = compile(`
|
|
107
|
+
'use client'
|
|
108
|
+
export function C({ keys, one }: { keys: string[]; one: string }) {
|
|
109
|
+
return <ul>{keys.filter(k => {
|
|
110
|
+
if (k === 'a') {
|
|
111
|
+
var one = 'a'
|
|
112
|
+
}
|
|
113
|
+
return k === one
|
|
114
|
+
}).map(k => <li key={k}>{k}</li>)}</ul>
|
|
115
|
+
}
|
|
116
|
+
`)
|
|
117
|
+
const tpl = templateSource(js)
|
|
118
|
+
expect(tpl).toContain('return k === one')
|
|
119
|
+
expect(tpl).not.toContain('_p.one')
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
describe('client analysis of the hydration payload (#3845)', () => {
|
|
124
|
+
test('closed-type rest keys the client reads are listed', () => {
|
|
125
|
+
const { ir } = compile(`
|
|
126
|
+
'use client'
|
|
127
|
+
export function C({ label, ...rest }: { label: string; tone?: string; size?: string }) {
|
|
128
|
+
return <button {...rest} onClick={() => {}}>{label}</button>
|
|
129
|
+
}
|
|
130
|
+
`)
|
|
131
|
+
expect(ir.metadata.clientAnalysis?.usedRestKeys).toEqual(['tone', 'size'])
|
|
132
|
+
expect(ir.metadata.clientAnalysis?.readsCallerBag).toBe(false)
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
test('a whole props-object spread onto a child reads the caller bag', () => {
|
|
136
|
+
const { ir } = compile(`
|
|
137
|
+
'use client'
|
|
138
|
+
function Chip(props: { label: string }) { return <button onClick={() => {}}>{props.label}</button> }
|
|
139
|
+
export function C(props: { label: string }) {
|
|
140
|
+
return <div><Chip {...props} /></div>
|
|
141
|
+
}
|
|
142
|
+
`)
|
|
143
|
+
expect(ir.metadata.clientAnalysis?.readsCallerBag).toBe(true)
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
test('a loop row named like the props object is not the caller bag', () => {
|
|
147
|
+
const { ir } = compile(`
|
|
148
|
+
'use client'
|
|
149
|
+
function Chip(p: { label: string }) { return <button onClick={() => {}}>{p.label}</button> }
|
|
150
|
+
export function C(props: { rows: { label: string }[] }) {
|
|
151
|
+
return <div>{props.rows.map((props) => <Chip key={props.label} {...props} />)}</div>
|
|
152
|
+
}
|
|
153
|
+
`)
|
|
154
|
+
expect(ir.metadata.clientAnalysis?.readsCallerBag).toBe(false)
|
|
155
|
+
})
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
describe('isHydrationPayloadPropName', () => {
|
|
159
|
+
test('`on[A-Z]` handlers and `__` plumbing stay out; `on`-prefixed data props travel', () => {
|
|
160
|
+
expect(isHydrationPayloadPropName('onClick')).toBe(false)
|
|
161
|
+
expect(isHydrationPayloadPropName('__instanceId')).toBe(false)
|
|
162
|
+
for (const name of ['on', 'one', 'only', 'once', 'online']) {
|
|
163
|
+
expect(isHydrationPayloadPropName(name)).toBe(true)
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
})
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* `.map()` of child components made the loop's array look, to
|
|
4
4
|
* `isArrayExprDirectPropRef` (jsx-to-ir.ts), like a local constant with no
|
|
5
5
|
* prop/signal origin. The loop was then classified `isStaticArray: true`
|
|
6
|
-
* and compiled to the static `
|
|
6
|
+
* and compiled to the static `childScopesBySlot` + `forEach` init path instead
|
|
7
7
|
* of `mapArray`. That static path's `renderChild()` calls (client runtime)
|
|
8
8
|
* carry no `bf-h`/`bf-m` scope-relationship attributes on a CSR-only mount
|
|
9
|
-
* (no existing SSR markup to hydrate against), so the `
|
|
9
|
+
* (no existing SSR markup to hydrate against), so the `childScopesBySlot`
|
|
10
10
|
* selector in the static init never matches — the row's child component
|
|
11
11
|
* never gets `initChild`ed, so its signals and event listeners never wire
|
|
12
12
|
* up. Found by the #2481 mutation sweep's `alias-props` mutation against
|
|
@@ -100,7 +100,7 @@ describe('#2724 — prop-alias keyed loop stays on mapArray, not the static path
|
|
|
100
100
|
}
|
|
101
101
|
`, 'AliasHop.tsx')
|
|
102
102
|
expect(clientJs).toMatch(/\bmapArray(Lazy)?\s*\(/)
|
|
103
|
-
expect(clientJs).not.toMatch(/
|
|
103
|
+
expect(clientJs).not.toMatch(/childScopesBySlot\(/)
|
|
104
104
|
})
|
|
105
105
|
|
|
106
106
|
test('local const derived from a whole-props member access uses mapArray', () => {
|
|
@@ -115,7 +115,7 @@ describe('#2724 — prop-alias keyed loop stays on mapArray, not the static path
|
|
|
115
115
|
}
|
|
116
116
|
`, 'MemberAlias.tsx')
|
|
117
117
|
expect(clientJs).toMatch(/\bmapArray(Lazy)?\s*\(/)
|
|
118
|
-
expect(clientJs).not.toMatch(/
|
|
118
|
+
expect(clientJs).not.toMatch(/childScopesBySlot\(/)
|
|
119
119
|
})
|
|
120
120
|
|
|
121
121
|
test('two-hop alias chain uses mapArray', () => {
|
|
@@ -131,7 +131,7 @@ describe('#2724 — prop-alias keyed loop stays on mapArray, not the static path
|
|
|
131
131
|
}
|
|
132
132
|
`, 'TwoHop.tsx')
|
|
133
133
|
expect(clientJs).toMatch(/\bmapArray(Lazy)?\s*\(/)
|
|
134
|
-
expect(clientJs).not.toMatch(/
|
|
134
|
+
expect(clientJs).not.toMatch(/childScopesBySlot\(/)
|
|
135
135
|
})
|
|
136
136
|
|
|
137
137
|
test('an alias of the WHOLE props object, accessed via property access, uses mapArray', () => {
|
|
@@ -202,7 +202,7 @@ describe('#2724 — prop-alias keyed loop stays on mapArray, not the static path
|
|
|
202
202
|
return <div>{ITEMS.map((item) => <Item key={item.label} label={item.label} />)}</div>
|
|
203
203
|
}
|
|
204
204
|
`, 'ModuleConst.tsx')
|
|
205
|
-
expect(clientJs).toMatch(/
|
|
205
|
+
expect(clientJs).toMatch(/childScopesBySlot\(/)
|
|
206
206
|
expect(clientJs).not.toMatch(/\bmapArray(Lazy)?\s*\(/)
|
|
207
207
|
})
|
|
208
208
|
|
|
@@ -221,7 +221,7 @@ describe('#2724 — prop-alias keyed loop stays on mapArray, not the static path
|
|
|
221
221
|
return <div>{state.items.map((item) => <Item key={item.label} label={item.label} />)}</div>
|
|
222
222
|
}
|
|
223
223
|
`, 'NameCollision.tsx')
|
|
224
|
-
expect(clientJs).toMatch(/
|
|
224
|
+
expect(clientJs).toMatch(/childScopesBySlot\(/)
|
|
225
225
|
expect(clientJs).not.toMatch(/\bmapArray(Lazy)?\s*\(/)
|
|
226
226
|
})
|
|
227
227
|
|
|
@@ -70,10 +70,13 @@ describe('#2754 — a caller-props forward earns a slot and an init', () => {
|
|
|
70
70
|
test('a spread of an ordinary object still inlines into the template and earns no slot', () => {
|
|
71
71
|
// Reverse direction: only the caller-props forward is unknowable at
|
|
72
72
|
// compile time. An ordinary object spread is fully emitted by both
|
|
73
|
-
// templates and must not start allocating slot ids.
|
|
73
|
+
// templates and must not start allocating slot ids. (Its value reads a
|
|
74
|
+
// name, so it stays a spread: a static literal one is expanded per key
|
|
75
|
+
// in Phase 1, #3844.)
|
|
74
76
|
const { clientJs, template } = compile(`
|
|
75
77
|
"use client";
|
|
76
|
-
const
|
|
78
|
+
const TITLE = 'x'
|
|
79
|
+
const extra = { title: TITLE }
|
|
77
80
|
export function Ordinary() {
|
|
78
81
|
return <span className="plain" {...extra} />
|
|
79
82
|
}
|
|
@@ -97,7 +97,7 @@ export function StaticNestedSignalCase() {
|
|
|
97
97
|
const js = compileClientJs(source)
|
|
98
98
|
// Pre-fix, this text was frozen at its SSR-baked value — no
|
|
99
99
|
// `createEffect` at all inside the inner forEach body.
|
|
100
|
-
expect(js).toMatch(/createEffect\(\(\) => \{ __bfw_\w+\('s\d+',
|
|
100
|
+
expect(js).toMatch(/createEffect\(\(\) => \{ __bfw_\w+\('s\d+', textOrNode\(count\(\)\)\) \}\)/)
|
|
101
101
|
})
|
|
102
102
|
|
|
103
103
|
test('a static outer loop with a nested .map() wires a reactive attr on the inner element', () => {
|
|
@@ -169,7 +169,7 @@ describe('#2835 — name collision with a whole-props type member is not prop-de
|
|
|
169
169
|
}
|
|
170
170
|
`, 'DestructuredRegression.tsx')
|
|
171
171
|
expect(clientJs).toMatch(/\bmapArray(Lazy)?\s*\(/)
|
|
172
|
-
expect(clientJs).not.toMatch(/
|
|
172
|
+
expect(clientJs).not.toMatch(/childScopesBySlot\(/)
|
|
173
173
|
})
|
|
174
174
|
|
|
175
175
|
test('regression guard: a renamed destructure ({ base: rows }) still resolves to mapArray', () => {
|
|
@@ -183,7 +183,7 @@ describe('#2835 — name collision with a whole-props type member is not prop-de
|
|
|
183
183
|
}
|
|
184
184
|
`, 'RenamedDestructureRegression.tsx')
|
|
185
185
|
expect(clientJs).toMatch(/\bmapArray(Lazy)?\s*\(/)
|
|
186
|
-
expect(clientJs).not.toMatch(/
|
|
186
|
+
expect(clientJs).not.toMatch(/childScopesBySlot\(/)
|
|
187
187
|
})
|
|
188
188
|
|
|
189
189
|
test('regression guard: a renamed destructure keeps a same-named module const static (no name collision through the rename)', () => {
|
|
@@ -212,7 +212,7 @@ describe('#2835 — name collision with a whole-props type member is not prop-de
|
|
|
212
212
|
}
|
|
213
213
|
`, 'WholePropsBodyDestructure.tsx')
|
|
214
214
|
expect(clientJs).toMatch(/\bmapArray(Lazy)?\s*\(/)
|
|
215
|
-
expect(clientJs).not.toMatch(/
|
|
215
|
+
expect(clientJs).not.toMatch(/childScopesBySlot\(/)
|
|
216
216
|
})
|
|
217
217
|
|
|
218
218
|
test('regression guard: direct `props.base` access still resolves to mapArray', () => {
|
|
@@ -226,7 +226,7 @@ describe('#2835 — name collision with a whole-props type member is not prop-de
|
|
|
226
226
|
}
|
|
227
227
|
`, 'DirectMemberAccessRegression.tsx')
|
|
228
228
|
expect(clientJs).toMatch(/\bmapArray(Lazy)?\s*\(/)
|
|
229
|
-
expect(clientJs).not.toMatch(/
|
|
229
|
+
expect(clientJs).not.toMatch(/childScopesBySlot\(/)
|
|
230
230
|
})
|
|
231
231
|
|
|
232
232
|
test('regression guard: a rest-spread sibling name is unaffected (no collision to guard against)', () => {
|
|
@@ -84,7 +84,7 @@ describe('#3044 — nested array off a destructured object prop uses mapArray, n
|
|
|
84
84
|
}
|
|
85
85
|
`, 'ReproChild.tsx')
|
|
86
86
|
expect(clientJs).toMatch(/\bmapArray(Lazy)?\s*\(/)
|
|
87
|
-
expect(clientJs).not.toMatch(/
|
|
87
|
+
expect(clientJs).not.toMatch(/childScopesBySlot\(/)
|
|
88
88
|
})
|
|
89
89
|
|
|
90
90
|
test('flags: `data.items.map(...)` is classified isPropDerivedArray / non-static', () => {
|
|
@@ -69,8 +69,9 @@ describe('#3688 — Phase 1 marks a props-object spread onto a child', () => {
|
|
|
69
69
|
expect(rest).not.toHaveProperty('propsObject')
|
|
70
70
|
const local = tagSpread(`
|
|
71
71
|
import { Tag } from './tag'
|
|
72
|
-
export function D(props: { tone?: string }) { const extra = { tone:
|
|
72
|
+
export function D(props: { tone?: string }) { const extra = { tone: props.tone }; return <p><Tag {...extra} /></p> }
|
|
73
73
|
`, 'D')
|
|
74
|
+
expect(local.kind).toBe('spread')
|
|
74
75
|
expect(local).not.toHaveProperty('propsObject')
|
|
75
76
|
})
|
|
76
77
|
})
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #3713 — Phase 1's props-object spread marker (`SpreadAttr.propsObject`)
|
|
3
|
+
* on a child component inside a loop row. The client's loop-row props
|
|
4
|
+
* builders merge a marked spread in source order through the shared
|
|
5
|
+
* `childPropsObjectExpr`, so the marker must be set on a row's
|
|
6
|
+
* `{...props}` and must not be set when a row binding named `props`
|
|
7
|
+
* shadows the props object.
|
|
8
|
+
*
|
|
9
|
+
* The end-to-end runtime check (mount, row update, hydration) lives in
|
|
10
|
+
* `packages/client/__tests__/runtime/issue-3713-props-spread-loop-row.test.ts`;
|
|
11
|
+
* the rendered output is pinned by the `component-*-in-loop-row` and
|
|
12
|
+
* `component-spread-props-in-static-loop-row` conformance fixtures.
|
|
13
|
+
*/
|
|
14
|
+
import { describe, test, expect } from 'bun:test'
|
|
15
|
+
import { analyzeComponent } from '../analyzer'
|
|
16
|
+
import { jsxToIR } from '../jsx-to-ir'
|
|
17
|
+
import type { IRNode, IRComponent, AttrValue } from '../types'
|
|
18
|
+
|
|
19
|
+
function findComponents(node: IRNode, name: string, out: IRComponent[] = []): IRComponent[] {
|
|
20
|
+
if (node.type === 'component' && node.name === name) out.push(node)
|
|
21
|
+
const children: IRNode[] = []
|
|
22
|
+
if ('children' in node && Array.isArray(node.children)) children.push(...(node.children as IRNode[]))
|
|
23
|
+
if (node.type === 'conditional') children.push(node.whenTrue, node.whenFalse)
|
|
24
|
+
for (const child of children) findComponents(child, name, out)
|
|
25
|
+
return out
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function tagSpreads(source: string, componentName: string): AttrValue[] {
|
|
29
|
+
const ctx = analyzeComponent(source, 'Repro.tsx', componentName)
|
|
30
|
+
const ir = jsxToIR(ctx)!
|
|
31
|
+
return findComponents(ir, 'Tag').map(tag => tag.props.find(p => p.name.startsWith('...'))!.value)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
describe('#3713 — the props-object spread marker in loop rows', () => {
|
|
35
|
+
test('a row spread of the props object is marked in every row shape', () => {
|
|
36
|
+
const spreads = tagSpreads(`
|
|
37
|
+
import { Tag } from './tag'
|
|
38
|
+
export function List(props: { items: string[]; groups: { id: string; cells: string[] }[]; tone?: string }) {
|
|
39
|
+
const fixed = ['x']
|
|
40
|
+
return (
|
|
41
|
+
<div>
|
|
42
|
+
<ul>{props.items.map((it) => <Tag key={it} {...props} label={it} />)}</ul>
|
|
43
|
+
<ol>{props.items.map((it) => <li key={it}>{props.tone ? <Tag {...props} /> : null}</li>)}</ol>
|
|
44
|
+
<nav>{fixed.map((it) => <Tag key={it} {...props} />)}</nav>
|
|
45
|
+
<dl>{props.groups.map((g) => <dd key={g.id}>{g.cells.map((c) => <Tag key={c} {...props} />)}</dd>)}</dl>
|
|
46
|
+
</div>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
`, 'List')
|
|
50
|
+
expect(spreads).toHaveLength(4)
|
|
51
|
+
for (const spread of spreads) expect(spread).toMatchObject({ kind: 'spread', propsObject: true })
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
test('a loop row named `props` shadows the props object and is not marked', () => {
|
|
55
|
+
const [spread] = tagSpreads(`
|
|
56
|
+
import { Tag } from './tag'
|
|
57
|
+
export function Shadow(props: { rows: { tone: string }[] }) {
|
|
58
|
+
const rows = props.rows
|
|
59
|
+
return <ul>{rows.map((props) => <Tag key={props.tone} {...props} />)}</ul>
|
|
60
|
+
}
|
|
61
|
+
`, 'Shadow')
|
|
62
|
+
expect(spread.kind).toBe('spread')
|
|
63
|
+
expect(spread).not.toHaveProperty('propsObject')
|
|
64
|
+
})
|
|
65
|
+
})
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #3861 — a spread of an object other than the component's own props onto
|
|
3
|
+
* a child component (`<Chip {...row} />`, a loop row's `{...r}`). The client
|
|
4
|
+
* merges it with the call's explicit props in source order, in the CSR
|
|
5
|
+
* template (`renderChild`) and in init (`spreadChildProps`), instead of
|
|
6
|
+
* dropping it. A const alias of a closed-type rest (`const a = rest`) is the
|
|
7
|
+
* rest itself, so its spread unrolls per key like `{...rest}` does.
|
|
8
|
+
*
|
|
9
|
+
* The rendered output is pinned by the `object-spread-loop-row-child`,
|
|
10
|
+
* `object-spread-prop-child` and `rest-alias-spread-child` fixtures; the
|
|
11
|
+
* runtime merge by `packages/client/__tests__/runtime/spread-child-props.test.ts`.
|
|
12
|
+
*/
|
|
13
|
+
import { describe, test, expect } from 'bun:test'
|
|
14
|
+
import { compileJSX } from '../compiler'
|
|
15
|
+
import { TestAdapter } from '../adapters/test-adapter'
|
|
16
|
+
|
|
17
|
+
const adapter = new TestAdapter()
|
|
18
|
+
|
|
19
|
+
function compile(source: string): { js: string; errors: string[] } {
|
|
20
|
+
const result = compileJSX(source, 'Repro.tsx', { adapter })
|
|
21
|
+
const js = result.files.filter(f => f.path.endsWith('.js')).map(f => f.content).join('\n')
|
|
22
|
+
return { js, errors: result.errors.map(e => `${e.code} ${e.message}`) }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const CHIP = `function Chip(props: { id?: string; label?: string; tone?: string; size?: number }) {
|
|
26
|
+
return <span data-id={props.id} data-tone={props.tone} data-size={props.size}>{props.label}</span>
|
|
27
|
+
}`
|
|
28
|
+
|
|
29
|
+
describe('#3861 — an object spread onto a child component', () => {
|
|
30
|
+
test('a loop row spread reaches the CSR template and each row init', () => {
|
|
31
|
+
const { js, errors } = compile(`'use client'
|
|
32
|
+
${CHIP}
|
|
33
|
+
type Row = { id: string; label: string }
|
|
34
|
+
export function List({ rows }: { rows: Row[] }) {
|
|
35
|
+
return <div>{rows.map(r => <Chip key={r.id} tone="base" {...r} />)}</div>
|
|
36
|
+
}`)
|
|
37
|
+
expect(errors).toEqual([])
|
|
38
|
+
expect(js).toContain(`renderChild('Chip`)
|
|
39
|
+
expect(js).toContain(`{tone: "base", ...r}`)
|
|
40
|
+
expect(js).toContain(`spreadChildProps({ get tone() { return "base" } }, () => (r()))`)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
test('an object prop spread merges with explicit props in source order', () => {
|
|
44
|
+
const { js, errors } = compile(`'use client'
|
|
45
|
+
${CHIP}
|
|
46
|
+
export function One({ row }: { row: { id: string; label: string } }) {
|
|
47
|
+
return <div><Chip label="ignored" {...row} id="fixed" /></div>
|
|
48
|
+
}`)
|
|
49
|
+
expect(errors).toEqual([])
|
|
50
|
+
expect(js).toContain(`{label: "ignored", ..._p.row, id: "fixed"}`)
|
|
51
|
+
expect(js).toContain(`spreadChildProps({ label: "ignored" }, () => (_p.row), { id: "fixed" })`)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
test('an object spread next to a props-object spread merges both as parts', () => {
|
|
55
|
+
const { js, errors } = compile(`'use client'
|
|
56
|
+
${CHIP}
|
|
57
|
+
export function Both(props: { row: { id: string }; tone?: string }) {
|
|
58
|
+
return <div><Chip label="d" {...props.row} {...props} tone="t" /></div>
|
|
59
|
+
}`)
|
|
60
|
+
expect(errors).toEqual([])
|
|
61
|
+
expect(js).toContain(`spreadChildProps({ label: "d" }, () => (_p.row), () => _p, { tone: "t" })`)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
test('an object spread an init-only local holds defers the child to init', () => {
|
|
65
|
+
const { js, errors } = compile(`'use client'
|
|
66
|
+
${CHIP}
|
|
67
|
+
export function Local({ n }: { n: string }) {
|
|
68
|
+
let count = 0
|
|
69
|
+
const extra = { id: n, label: 'L' + (count++) }
|
|
70
|
+
return <div><Chip {...extra} /></div>
|
|
71
|
+
}`)
|
|
72
|
+
expect(errors).toEqual([])
|
|
73
|
+
expect(js).toContain('data-bf-ph="s0"')
|
|
74
|
+
expect(js).toContain(`upsertChild(__scope, 'Chip`)
|
|
75
|
+
expect(js).toContain('spreadChildProps(() => (extra))')
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
test('an object spread before a rest bag merges the bag as a later part', () => {
|
|
79
|
+
const { js, errors } = compile(`'use client'
|
|
80
|
+
${CHIP}
|
|
81
|
+
export function Mixed({ row, className, ...rest }: { row: { id: string }; className?: string; [key: string]: unknown }) {
|
|
82
|
+
return <div><Chip {...row} {...rest} tone={className} /></div>
|
|
83
|
+
}`)
|
|
84
|
+
expect(errors).toEqual([])
|
|
85
|
+
expect(js).toContain(`spreadChildProps(() => (_p.row), forwardProps(_p, {}, ["row","className"]), { get tone() { return _p.className } })`)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
test('a const alias of a closed rest unrolls per key and leaves out the destructured keys', () => {
|
|
89
|
+
const { js, errors } = compile(`'use client'
|
|
90
|
+
${CHIP}
|
|
91
|
+
export function Alias({ label, ...rest }: { label: string; tone?: string; size?: number }) {
|
|
92
|
+
const a = rest
|
|
93
|
+
const b = a
|
|
94
|
+
return <div><Chip {...b} tone="override" label={label} /><Chip {...a} /></div>
|
|
95
|
+
}`)
|
|
96
|
+
expect(errors).toEqual([])
|
|
97
|
+
expect(js).toContain(`{tone: _p.tone, size: _p.size, tone: "override", label: _p.label}`)
|
|
98
|
+
expect(js).toContain(`{tone: _p.tone, size: _p.size}, undefined, 's1'`)
|
|
99
|
+
expect(js).toContain(`{ get tone() { return _p.tone }, get size() { return _p.size } }`)
|
|
100
|
+
expect(js).not.toContain('forwardProps(')
|
|
101
|
+
})
|
|
102
|
+
})
|
|
@@ -13,6 +13,8 @@ describe('lookupLiteralConst (#3312)', () => {
|
|
|
13
13
|
const consts = constantsOf(`
|
|
14
14
|
const enabled = false
|
|
15
15
|
const limit = -2
|
|
16
|
+
const nz = -0
|
|
17
|
+
const big = 1e21
|
|
16
18
|
const missing = null
|
|
17
19
|
export function C() {
|
|
18
20
|
const on = true
|
|
@@ -20,7 +22,7 @@ export function C() {
|
|
|
20
22
|
const ratio = 1.5
|
|
21
23
|
const multiline = 'a\\nb'
|
|
22
24
|
const derived = mode + '!'
|
|
23
|
-
return <div data-x={on && enabled ? mode : String(limit + ratio) + derived + multiline} data-m={missing ?? 'm'}>x</div>
|
|
25
|
+
return <div data-x={on && enabled ? mode : String(limit + ratio + nz + big) + derived + multiline} data-m={missing ?? 'm'}>x</div>
|
|
24
26
|
}
|
|
25
27
|
`)
|
|
26
28
|
const never = () => false
|
|
@@ -28,8 +30,12 @@ export function C() {
|
|
|
28
30
|
test('resolves boolean, number, string and null literals at module and function scope', () => {
|
|
29
31
|
expect(lookupLiteralConst('on', consts, never)).toEqual({ kind: 'boolean', text: 'true' })
|
|
30
32
|
expect(lookupLiteralConst('enabled', consts, never)).toEqual({ kind: 'boolean', text: 'false' })
|
|
31
|
-
expect(lookupLiteralConst('limit', consts, never)).toEqual({ kind: 'number', text: '-2' })
|
|
32
|
-
expect(lookupLiteralConst('ratio', consts, never)).toEqual({ kind: 'number', text: '1.5' })
|
|
33
|
+
expect(lookupLiteralConst('limit', consts, never)).toEqual({ kind: 'number', text: '-2', value: -2 })
|
|
34
|
+
expect(lookupLiteralConst('ratio', consts, never)).toEqual({ kind: 'number', text: '1.5', value: 1.5 })
|
|
35
|
+
// A number carries its value: `-0` keeps its sign, which `text` cannot (#3824 step 6).
|
|
36
|
+
const nz = lookupLiteralConst('nz', consts, never)
|
|
37
|
+
expect(nz?.kind === 'number' && Object.is(nz.value, -0)).toBe(true)
|
|
38
|
+
expect(lookupLiteralConst('big', consts, never)).toEqual({ kind: 'number', text: '1e+21', value: 1e21 })
|
|
33
39
|
expect(lookupLiteralConst('mode', consts, never)).toEqual({ kind: 'string', text: 'on' })
|
|
34
40
|
expect(lookupLiteralConst('multiline', consts, never)).toEqual({ kind: 'string', text: 'a\nb' })
|
|
35
41
|
expect(lookupLiteralConst('missing', consts, never)).toEqual({ kind: 'null', text: 'null' })
|
|
@@ -137,7 +137,7 @@ describe('nested loop: referencing an OUTER loop\'s own index (#2861)', () => {
|
|
|
137
137
|
// outer accessor must be read directly by name, exactly as `item()`
|
|
138
138
|
// reads the outer ITEM in the sibling case #2865 already covers.
|
|
139
139
|
expect(content).toMatch(
|
|
140
|
-
/mapArray\(\(\) => g\(\)\.items \|\| \[\], .*?, \(it, __innerIdx\d+_\d+, __existing\) => \{[\s\S]*?createEffect\(\(\) => \{ __bfw_s0\('s0',
|
|
140
|
+
/mapArray\(\(\) => g\(\)\.items \|\| \[\], .*?, \(it, __innerIdx\d+_\d+, __existing\) => \{[\s\S]*?createEffect\(\(\) => \{ __bfw_s0\('s0', textOrNode\(gi\(\)\)\) \}\)/
|
|
141
141
|
)
|
|
142
142
|
})
|
|
143
143
|
|
|
@@ -202,7 +202,7 @@ describe('nested loop: referencing an OUTER loop\'s own index (#2861)', () => {
|
|
|
202
202
|
// ONE LEVEL UP (the one whose conditional this branch belongs to) was
|
|
203
203
|
// classified 'none' and baked once into the branch's initial template.
|
|
204
204
|
expect(content).toMatch(
|
|
205
|
-
/mapArray\(\(\) => o\(\)\.items \|\| \[\], .*?, \(item, __bidxbr_\d+, __existing\) => \{[\s\S]*?createEffect\(\(\) => \{ __bfw_s1\('s1',
|
|
205
|
+
/mapArray\(\(\) => o\(\)\.items \|\| \[\], .*?, \(item, __bidxbr_\d+, __existing\) => \{[\s\S]*?createEffect\(\(\) => \{ __bfw_s1\('s1', textOrNode\(oi\(\)\)\) \}\)/
|
|
206
206
|
)
|
|
207
207
|
})
|
|
208
208
|
})
|
|
@@ -235,7 +235,7 @@ describe('.map() row: object-literal key / shorthand / member positions vs. the
|
|
|
235
235
|
// The genuine index references (passed to the child, and read directly
|
|
236
236
|
// in the row's own text) are still wrapped as accessor calls.
|
|
237
237
|
expect(js).toContain('return i()')
|
|
238
|
-
expect(js).toContain('
|
|
238
|
+
expect(js).toContain('textOrNode(i())')
|
|
239
239
|
})
|
|
240
240
|
})
|
|
241
241
|
|
|
@@ -117,7 +117,7 @@ describe('planLoop', () => {
|
|
|
117
117
|
refuse: (message) => refusals.push(message),
|
|
118
118
|
}
|
|
119
119
|
expect(spellSortedSource(null, 'xs', spelling)).toBe('xs')
|
|
120
|
-
const evaluated = spellSortedSource({ kind: 'eval', helper: 'sort_eval', operands: [{ kind: 'string', value: 'body' }], captured: ['k'] }, 'xs', spelling)
|
|
120
|
+
const evaluated = spellSortedSource({ kind: 'eval', helper: 'sort_eval', operands: [{ kind: 'string', value: 'body' }], captured: [{ name: 'k', value: { kind: 'identifier', name: 'k' } }] }, 'xs', spelling)
|
|
121
121
|
expect(evaluated).toBe(`sort_eval(xs, 'body', {k: v.k})`)
|
|
122
122
|
const structured = plan(`export function Test(props: { items: { name: string }[] }) { return <ul>{props.items.toSorted((a, b) => a.name.localeCompare(b.name)).map(x => <li key={x.name}>{x.name}</li>)}</ul> }`)
|
|
123
123
|
expect(spellSortedSource(structured.sort, 'xs', spelling)).toBe('sort(xs, name)')
|