Skip to content

refactor(dom): route all DOM access through the Dom module, type it with VNode interfaces - #1441

Open
xdan wants to merge 1 commit into
mainfrom
refactor/dom-vnode-abstraction
Open

refactor(dom): route all DOM access through the Dom module, type it with VNode interfaces#1441
xdan wants to merge 1 commit into
mainfrom
refactor/dom-vnode-abstraction

Conversation

@xdan

@xdan xdan commented Aug 11, 2026

Copy link
Copy Markdown
Owner

What

Groundwork for moving the editor to virtual-DOM editing. No public API changes — parameter types are only widened, return types untouched.

  • New src/types/vdom.d.ts: VNode / VElement / VHTMLElement / VStyle / VText / VFragment / VDocument — a minimal structural subset of the browser DOM. Browser nodes satisfy these interfaces, so all existing call sites compile unchanged.
  • Dom module is typed against the subset (mutation/structural core: append, prepend, after, before, appendChildFirst, detach, unwrap, moveContent, sibling, hide/show) and deduplicated: first/last share one traversal, prevWithClass/nextWithClass share one helper, after/appendChildFirst simplified, temporaryList no longer uses querySelectorAll.
  • Contract test: a new Virtual DOM contract suite in dom.test.js runs Dom against a hand-rolled non-browser VNode implementation, pinning the "Dom relies only on the subset" invariant at runtime.
  • Full sweep of core / modules / plugins / jodit.ts (file by file):
    • 0 direct appendChild / insertBefore / removeChild / replaceChild left outside the Dom module (was ~207 call sites);
    • .style. property access → css() or VStyle methods (getPropertyValue/setProperty for exact inline reads and CSS custom properties);
    • get/setAttributeattr();
    • querySelector reduced 36 → 4 sanctioned call sites (user-supplied selectors in selector.ts, pasted-stylesheet selectors in apply-styles.ts, BASE_PATH bootstrap in constants.ts).
  • Sanitizers keep raw attribute access on purpose (safe-html.ts, clean-html/allow-attributes.ts): attr() kebab-cases keys (onLoadon-load), which a sanitizer must never do. Commented in place.
  • VDOM-MIGRATION-IDEAS.md: follow-ups that need a minor release (NodeCondition on VNode, css()/cssInline split, attr.raw, guards narrowing to V-types, dialog registry) and the fundamental VDOM blockers (Range/Selection, layout measurements, beforeinput as the diff source).

Checks

  • Chrome: 2150 SUCCESS (includes 6 new VNode contract tests)
  • Firefox: 2150 SUCCESS
  • make lint: 0 errors (3 pre-existing complexity warnings), no circular dependencies
  • tsc --noEmit: clean

🤖 Generated with Claude Code

…ith VNode interfaces

Preparation for virtual-DOM editing (no public API changes):

- New src/types/vdom.d.ts: VNode/VElement/VHTMLElement/VStyle/VText/
  VFragment/VDocument — a minimal structural subset of the browser DOM.
  Browser nodes satisfy the interfaces, so every call site compiles as is.
- Dom module: mutation/structural core (append, prepend, after, before,
  appendChildFirst, detach, unwrap, moveContent, sibling, hide/show) is
  typed against VNode; moveContent/sibling get overloads so explicitly
  typed user callbacks keep compiling. Deduplicated first/last
  (__deepMost), prevWithClass/nextWithClass (__siblingWithClass),
  simplified after/appendChildFirst, temporaryList no longer uses
  querySelectorAll.
- The contract is pinned by a new 'Virtual DOM contract' suite in
  dom.test.js: Dom methods run against a hand-rolled non-browser VNode
  implementation.
- Codebase sweep (core, modules, plugins, jodit.ts): no direct
  appendChild/insertBefore/removeChild/replaceChild left outside the Dom
  module; .style. property access replaced with css()/VStyle methods;
  get/setAttribute with attr(); querySelector reduced from 36 call sites
  to 4 sanctioned ones (user-supplied selectors, pasted stylesheets,
  BASE_PATH bootstrap).
- Sanitizers (safe-html, clean-html/allow-attributes) intentionally keep
  raw attribute access: attr() kebab-cases names, a sanitizer must not.
- VDOM-MIGRATION-IDEAS.md collects the follow-ups that need a minor
  release (NodeCondition on VNode, css()/cssInline split, attr.raw,
  guards narrowing to V-types) and the fundamental VDOM blockers.
@github-actions github-actions Bot added plugins Editor plugins core Core / modules tests Tests documentation Docs / README labels Aug 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📊 Bundle Size

Asset Reference Current Diff
jodit.fat.min.js 734.89 KB 736.25 KB 🔺 +1.35 KB
jodit.fat.min.css 157.96 KB 157.96 KB
Total 892.85 KB 894.21 KB 🔺 +1.35 KB
Validation details
Preparing data for Statoscope report...

✅ All checks passed · Full diff report → (see Artifacts)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core / modules documentation Docs / README plugins Editor plugins tests Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant