Skip to content

Commit 9de7ea9

Browse files
committed
Add declarative DOM helpers for UI code
- New src/client/dom.ts with el() hyperscript builder, show/hide/visible display toggles, and byId() typed element lookup - Add jsdom dev dependency for DOM testing - 29 tests covering element creation, event wiring, visibility, and lookups - Update CODING_STANDARDS.md with DOM helper guidance - Apply Biome auto-format to client and server files
1 parent c036cdb commit 9de7ea9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2544
-1773
lines changed

docs/CODING_STANDARDS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ Classes are acceptable in places like:
3535

3636
These files coordinate long-lived state, timers, DOM, canvas, sockets, or platform APIs. That is a legitimate use of classes in this project.
3737

38+
### DOM helpers
39+
40+
Use `src/client/dom.ts` helpers for declarative DOM construction in UI code:
41+
42+
- **`el(tag, props, ...children)`** — Create elements with class, text, handlers, and children in one expression instead of multi-line createElement/className/addEventListener/appendChild chains.
43+
- **`visible(el, condition)` / `show(el)` / `hide(el)`** — Toggle display instead of writing `.style.display = condition ? 'block' : 'none'` everywhere.
44+
- **`byId(id)`** — Typed `getElementById` that throws on missing elements, replacing `document.getElementById('x')!` non-null assertions.
45+
46+
Prefer `el()` for building element trees programmatically. Continue using `innerHTML` for complex HTML templates where `el()` would be awkward.
47+
3848
## Refactoring Guidance
3949

4050
- Prefer extracting pure helper modules before introducing new patterns or libraries.

0 commit comments

Comments
 (0)