@pyreon/preact-compat 0.21.0 → 0.23.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/README.md +86 -99
- package/lib/_chunks/jsx-runtime-D77N0lwB.js +157 -0
- package/lib/analysis/index.js.html +1 -1
- package/lib/hooks.js +1 -11
- package/lib/index.js +4 -0
- package/lib/jsx-runtime.js +2 -150
- package/package.json +5 -5
- package/src/index.ts +13 -0
- package/src/tests/new-apis.test.ts +43 -0
- package/lib/analysis/hooks.js.html +0 -5406
- package/lib/analysis/jsx-runtime.js.html +0 -5406
- package/lib/analysis/signals.js.html +0 -5406
|
@@ -548,6 +548,49 @@ describe('toChildArray', () => {
|
|
|
548
548
|
test('handles single non-array child', () => {
|
|
549
549
|
expect(toChildArray('hello')).toEqual(['hello'])
|
|
550
550
|
})
|
|
551
|
+
|
|
552
|
+
// Regression: the Pyreon compiler's prop-inlining pass rewrites
|
|
553
|
+
// `<MyComp>{data.map(fn)}</MyComp>` (any non-stable children
|
|
554
|
+
// expression) as `MyComp({ children: () => data.map(fn) })`. Pre-fix
|
|
555
|
+
// `flatten()` treated the wrapping function as a single child —
|
|
556
|
+
// `toChildArray()` silently returned `[function]` instead of the N
|
|
557
|
+
// real children. Same bug class as PR #197 / PR #736.
|
|
558
|
+
//
|
|
559
|
+
// Fix: `flatten()` unwraps function children at entry, mirroring the
|
|
560
|
+
// kinetic / Iterator pattern.
|
|
561
|
+
//
|
|
562
|
+
// Bisect-verified: removing the `typeof value === 'function'` branch
|
|
563
|
+
// from `flatten()` fails every spec below with "expected … to have a
|
|
564
|
+
// length of N but got 1".
|
|
565
|
+
describe('compiler function-wrap unwrap', () => {
|
|
566
|
+
const realChildren = [pyreonH('div', null, 'a'), pyreonH('div', null, 'b')] as VNodeChild[]
|
|
567
|
+
|
|
568
|
+
test('function-wrapped children expand to N real children', () => {
|
|
569
|
+
const wrapped = (() => realChildren) as unknown as VNodeChild
|
|
570
|
+
expect(toChildArray(wrapped)).toHaveLength(2)
|
|
571
|
+
})
|
|
572
|
+
|
|
573
|
+
test('function wrapping a single child unwraps', () => {
|
|
574
|
+
const wrapped = (() => pyreonH('span', null, 'only')) as unknown as VNodeChild
|
|
575
|
+
const arr = toChildArray(wrapped)
|
|
576
|
+
expect(arr).toHaveLength(1)
|
|
577
|
+
})
|
|
578
|
+
|
|
579
|
+
test('function wrapping null returns empty array', () => {
|
|
580
|
+
const wrappedNull = (() => null) as unknown as VNodeChild
|
|
581
|
+
expect(toChildArray(wrappedNull)).toEqual([])
|
|
582
|
+
})
|
|
583
|
+
|
|
584
|
+
test('function wrapping nested arrays still flattens', () => {
|
|
585
|
+
const wrapped = (() =>
|
|
586
|
+
[pyreonH('a', null), [pyreonH('b', null), pyreonH('c', null)]]) as unknown as VNodeChild
|
|
587
|
+
expect(toChildArray(wrapped)).toHaveLength(3)
|
|
588
|
+
})
|
|
589
|
+
|
|
590
|
+
test('plain (non-wrapped) children still work — fix is additive', () => {
|
|
591
|
+
expect(toChildArray(realChildren)).toHaveLength(2)
|
|
592
|
+
})
|
|
593
|
+
})
|
|
551
594
|
})
|
|
552
595
|
|
|
553
596
|
describe('Component class', () => {
|