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:
- The utility will export a
vdomToString(vdom) function that recursively traverses the VDOM object.
- It will check if each object key is a valid JavaScript identifier.
- Valid identifiers will be written to the output string without quotes (e.g.,
tag:).
- Invalid identifiers (e.g.,
data-foo) will be correctly wrapped in single quotes (e.g., 'data-foo':).
- It will handle the build-time placeholders for runtime expressions, outputting them as raw, unquoted code.
- This new utility will completely replace the
JSON.stringify and subsequent regex calls in the build scripts.
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:
buildScripts/util/vdomToString.mjs.vdomToString(vdom)function that recursively traverses the VDOM object.tag:).data-foo) will be correctly wrapped in single quotes (e.g.,'data-foo':).JSON.stringifyand subsequent regex calls in the build scripts.