LearnNewsExamplesServices
Frontmatter
id7148
titleCreate a Robust VDOM-to-String Serializer
stateClosed
labels
enhancement
assigneestobiu
createdAtAug 1, 2025, 1:06 AM
updatedAtAug 2, 2025, 2:47 PM
githubUrlhttps://github.com/neomjs/neo/issues/7148
authortobiu
commentsCount1
parentIssue7130
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtAug 2, 2025, 2:47 PM

Create a Robust VDOM-to-String Serializer

Closed v10.3.0 enhancement
tobiu
tobiu commented on Aug 1, 2025, 1:06 AM

Description: The JSON.stringify + regex method for generating the VDOM string during the build process is flawed. It incorrectly handles object keys that are not valid JavaScript identifiers (e.g., data-foo) and produces non-idiomatic code (quoted keys). A dedicated serializer is required for correctness and code quality.

Implementation Details:

  • Tool: A new, custom utility module.
  • Location: buildScripts/util/vdomToString.mjs.
  • Method:
    1. The utility will export a vdomToString(vdom) function that recursively traverses the VDOM object.
    2. It will check if each object key is a valid JavaScript identifier.
    3. Valid identifiers will be written to the output string without quotes (e.g., tag:).
    4. Invalid identifiers (e.g., data-foo) will be correctly wrapped in single quotes (e.g., 'data-foo':).
    5. It will handle the build-time placeholders for runtime expressions, outputting them as raw, unquoted code.
    6. This new utility will completely replace the JSON.stringify and subsequent regex calls in the build scripts.
tobiu assigned to @tobiu on Aug 1, 2025, 1:06 AM
tobiu added the enhancement label on Aug 1, 2025, 1:06 AM
tobiu added parent issue #7130 on Aug 1, 2025, 1:06 AM
tobiu
tobiu Aug 2, 2025, 2:47 PM

resolved

tobiu closed this issue on Aug 2, 2025, 2:47 PM