Skip to content

Commit 1581286

Browse files
hyperpolymathclaude
andcommitted
feat(safe-dom): add minimal SafeDOM package and runnable example
Introduces tools/safe-dom/ as a standalone ReScript workspace package implementing the SafeDOM surface the orphaned examples/SafeDOMExample.res already assumed: - ProvenSelector / ProvenHTML: validated-input wrappers (boundary check is carried in the type so mount cannot fail on input shape). - mount: proven-input mounting that returns mountResult variant. - mountSafe / mountWhenReady: string-input helpers that validate at the boundary and dispatch via callbacks. - mountBatch: two-phase (validate + existence check, then mutate) for best-effort atomic batch mounting; the trade-off (innerHTML mutations are not transactionally reversible if the DOM races mid-batch) is documented in-source. Moves examples/SafeDOMExample.res into the package so the build verifies the surface. Fixes three latent bugs in the example uncovered by the first build: 1. mountWithValidation had 6 opening braces and 5 closing - outer switch was never closed. 2. Console.log("label", value) used JS-style varargs; switched to RescriptCore's Console.log2 / Console.error2. 3. Template literal interpolating Array.length(...) needed ->Int.toString (no implicit int-to-string in ReScript). package-lock.json appears at the repo root because npm hoisted the workspace on install - committing it locks the resolved tree across the workspace. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 9d663eb commit 1581286

7 files changed

Lines changed: 3846 additions & 9 deletions

File tree

0 commit comments

Comments
 (0)