Skip to content

feat: lossless HTML-node roundtrip (hybrid DOM-native nodes)#194

Open
Zen0-99 wants to merge 6 commits into
CoreBunch:mainfrom
Zen0-99:hybrid-dom-native-nodes
Open

feat: lossless HTML-node roundtrip (hybrid DOM-native nodes)#194
Zen0-99 wants to merge 6 commits into
CoreBunch:mainfrom
Zen0-99:hybrid-dom-native-nodes

Conversation

@Zen0-99

@Zen0-99 Zen0-99 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Imported HTML is now preserved exactly through the full edit-and-publish round-trip — when you bring real-world HTML into the builder and publish it back out, no markup, attributes, classes, inline styles, or structure is lost.

Behind that user-facing guarantee, this introduces the DOM-native node model and wires the importer and publisher through a single, unified render path:

  • Every base module now declares an htmlContract.
  • The HTML importer (walkAndMap / rules) and the publisher (renderNode and the unified render path) share one serialization contract, so what comes in is what goes out.
  • DOM-native node rendering is added to the canvas, with upstream attribute sanitization applied to the DOM-native-first importer.

Why

  • Lossless fidelity: Real-world HTML must survive import → edit → publish without silently dropping structure, attributes, or styling. This closes that gap.
  • DOM-native foundation: It lays the groundwork for a new DOM-native node type and canvas editing of raw/arbitrary HTML, so the builder can round-trip content it doesn't have a dedicated module for.

Test

Automated

  • bun test src/__tests__/architecture/hybrid-dom-native-nodes.test.ts — architecture/round-trip contract.
  • bun test src/__tests__/htmlImportmapping, structurePreservation, svgMapping, textNormalize.
  • bun test — full unit suite.
  • bun test tests/e2e/visual-builder.e2e.ts — end-to-end visual builder (or bun run test:e2e).

Manual

  1. Import an HTML document containing nested elements, custom attributes, classes, and inline styles.
  2. Confirm the canvas renders the nodes faithfully (DOM-native nodes preserve the source markup).
  3. Edit and republish, then diff the published output HTML against the source to confirm nothing was lost or mangled.

Implement lossless roundtrip between authored HTML and the DOM-native node
model so imported markup is preserved exactly through edit and publish.

- Phase 0/1: all base modules declare htmlContract; DOM-native node model
  and canvas renderers introduced.
- Phase 2: publisher serializes from HTML fields via a unified render path.
- Complete migration (phases 0-7): rules, walk/map importer, attribute
  sanitization, and publisher wired end-to-end.
- Apply upstream attribute sanitization to the DOM-native-first importer.
@Zen0-99 Zen0-99 force-pushed the hybrid-dom-native-nodes branch from e307896 to 806d21a Compare July 8, 2026 19:01
Adopt upstream changes:
- scripts/e2e-dev.ts: use viteCommand from bunCommand
- src/core/publisher/renderLoop.ts: pass config.mediaAssets to injectNodeInlineStyles
- src/core/publisher/renderNode.ts: pass config.mediaAssets to injectNodeInlineStyles in both standard and unified node paths

Preserve hybrid DOM-native node rendering logic and cleanMode guard.
- Map ImportBodyAttributes.attributes (new upstream shape) through assetPlan
  normalization and applyAssetRewrites rewriting instead of the removed .props
- Apply imported body attributes to rootNode.props.htmlAttributes in site helpers
- Fix prefer-const lint in renderUnifiedNode
- Guard undefined render/preview in pluginModuleComponentFactory
- Fix no-unsafe-finally lint in createDbClient.test.ts
- Break NodeRenderer <-> DomNodeRenderer import cycle by passing ChildRenderer as prop
- Break forms index.ts <-> htmlContracts.ts cycle by moving prop schemas/types to forms/types.ts
- Fix no-css-var-fallbacks violation in DomNodeProperties.module.css
- Extract createDomNode/syncModuleOverlayHtmlFields to page-tree/domMutations.ts
  and ratchet mutations.ts module-size cap down to 766
- Grandfather agent executor.ts (734 lines) with note to extract DOM-native tool runners
- Fix Windows path bug in error-boundary-coverage test
- Sync plugin bootstrap artifacts via bootstrap:sync
- Use @core/page-tree barrel import in hybrid-dom-native-nodes architecture test
- parseVCNode: reject VC nodes with empty moduleId so structurally invalid VC nodes are dropped again
- migrateOldFormatNodes: exclude Visual Component trees from DOM-native migration; VCs are module-based by design
- migrateOldFormatNodes: only migrate modules whose htmlContract resolves to a real HTML tag, preserving base.visual-component-ref and base.slot-instance as module nodes
- Update stale htmlPagePlan.test.ts to match Phase 3 claim semantics (raw <form> becomes DOM-native; label and button submit get overlays)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants