bi-03 step 02 — Observe, then build the tree builder
Goal
Establish the browser as the oracle, then write a tree builder that agrees with it.
Tasks
-
Capture the oracle. Open each fixture from
file://in Chrome, pastesrc/show.jsinto the console, and save the output tosrc/observed/<case>.txt. Keep exact whitespace. -
Score your predictions honestly: exact / structurally right, details wrong / wrong.
-
Write
src/foster.js, exportingbuildTree(tokens). Under ~80 lines, no dependencies. Implement only: a stack of open elements, theinBodyandinTableinsertion modes, anappropriateInsertionPlace(fosterParenting)function, and the<input type=hidden>exception. -
Run the harness.
node run.mjs a # your output node check.mjs # diff against the browserCases a, b, d must pass exactly. Case c is the stretch goal.
-
If you attempt case c, do not fix the diff blindly. Read it: it is telling you precisely what the in-table-text character sub-mode is for.
Done when
- All four observed files captured
- Predictions scored
-
node check.mjspasses cases a, b, d -
You can explain why case A's
worldtext lands inside thedivand not before the table