J json-to-dom
Execution flow

How it works.

From a plain JSON specification to a live browser DOM element, json-to-dom executes a deterministic, multi-stage compilation pipeline.

The 6-Stage Compilation Flow

[ JSON Specification ]
        │
        ▼
1. Normalize Input       ──► Normalizes arguments & event options (1.normalizeInput.js)
        │
        ▼
2. Grammar Validation    ──► Checks tagDef & allowed attributes against W3C dictionary
        │
        ▼
3. Recursive Traversal   ──► Compiles child specs depth-first (buildChildrenNodes.js)
        │
        ▼
4. Element Builder (0-5) ──► 0.createElement ──► 1.applyText ──► 2.applyProps ──► 3.applyAttrs ──► 4.applyClass ──► 5.appendChildren
        │
        ▼
5. Event Story (Stage 6) ──► Chapter 1: isEventAllowed ──► Chapter 2: internal hooks ──► Chapter 3: declared listeners
        │
        ▼
[ Live DOM Node / Fragment ]

The 7-Step Element Builder

Every element is constructed sequentially through dedicated step files in src/v11/elementBuilder/:

  • 0.createElement.js — Native element creation.
  • 1.applyTextContent.js — Guarded by tag allowance.
  • 2.applyProperties.js — Native element properties.
  • 3.applyAttributes.js — Whitelisted HTML attributes.
  • 4.applyClassList.js — String and array class lists.
  • 5.appendChildren.js — Appends recursive children.
  • 6.applyEvents.js — Optional & configurable events.

Configuring & Stopping Events

Event hooking is decoupled and completely opt-out:

  • Stop All Events: buildSpecElement({ inSpec, inApplyEvents: false })
  • Stop Internal Hooks Only: inAttachInternal: false or inApplyEvents: { internal: false }
  • Stop Declared Events Only: inApplyEvents: { declared: false }
  • Per-Element Stop: In spec: { "tagName": "button", "attachInternal": false }
  • Live Inspection: element.__ksEvents records { internal: [...], declared: [...] }