Support null and undefined in JrxNode type

Split JrxNode into JrxElement (concrete branded object) and JrxNode
(JrxElement | null | undefined), mirroring React's ReactElement vs
ReactNode pattern. Components can now return null/undefined to render
nothing.

- Rename isJrxNode to isJrxElement (deprecated alias kept)
- Handle null-returning components in jsx/jsxs factories
- Add tests for null/undefined returns, children filtering, render()
  rejection

Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
2026-03-14 01:06:22 +00:00
parent 00a5e83e8b
commit 4dcd184de0
6 changed files with 126 additions and 58 deletions

View File

@@ -300,7 +300,15 @@ describe("state passthrough", () => {
// =============================================================================
describe("error handling", () => {
it("throws for non-JrxNode input", () => {
expect(() => render({} as JrxNode)).toThrow(/expects a JrxNode/);
it("throws for non-JrxElement input", () => {
expect(() => render({} as JrxNode)).toThrow(/expects a JrxElement/);
});
it("throws when given null", () => {
expect(() => render(null)).toThrow(/expects a JrxElement/);
});
it("throws when given undefined", () => {
expect(() => render(undefined)).toThrow(/expects a JrxElement/);
});
});