You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(compiler-dom): leave out boolean attributes with falsy constant values when stringifying - #15910
When a static subtree gets stringified, a constant binding on a boolean attribute is only left out if its source is exactly false (#6568), or if it is hidden with a number. Any other falsy constant is printed as the attribute's value:
<input :disabled="0"> <!-- stringified as <input disabled="0"> -->
<input :checked="!1"> <!-- stringified as <input checked="false"> -->
A boolean attribute is on whenever it is present, so these inputs end up disabled/checked. At runtime and in SSR (includeBooleanAttr), the same bindings leave the attribute out. So the result depends on whether the surrounding markup reaches the stringify thresholds. I found this by rendering random static templates with and without stringification in jsdom and comparing the DOM. For example, :disabled="0" on a <textarea> came out disabled only when stringified.
This applies the existing hidden check to every boolean attribute and every falsy constant (0, -0, !1, 1 > 2, ...), using includeBooleanAttr like the runtime does.
The new stringifyStatic.spec.ts cases fail without the change. vitest run for compiler-dom/core/sfc and server-renderer (1651 tests), tsc --noEmit, ESLint and Prettier pass.
Summary by CodeRabbit
Bug Fixes
Static HTML output now correctly omits boolean attributes, including disabled, checked, and hidden, when their bound values are false.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Static stringification now omits constant false values for boolean attributes and hidden. Tests cover disabled and checked with four falsy expressions.
The omission check now covers boolean attributes and hidden when includeBooleanAttr returns false. Tests verify that four falsy expressions produce repeated <input> elements without disabled or checked.
Static rendering omits false boolean attributes while preserving empty-string and string-valued hidden attributes, consistent with runtime behavior. No merge-blocking risk is established.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and concisely describes the main change: omitting boolean attributes when constant values are falsy during static stringification.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a static subtree gets stringified, a constant binding on a boolean attribute is only left out if its source is exactly
false(#6568), or if it ishiddenwith a number. Any other falsy constant is printed as the attribute's value:A boolean attribute is on whenever it is present, so these inputs end up disabled/checked. At runtime and in SSR (
includeBooleanAttr), the same bindings leave the attribute out. So the result depends on whether the surrounding markup reaches the stringify thresholds. I found this by rendering random static templates with and without stringification in jsdom and comparing the DOM. For example,:disabled="0"on a<textarea>came out disabled only when stringified.This applies the existing
hiddencheck to every boolean attribute and every falsy constant (0,-0,!1,1 > 2, ...), usingincludeBooleanAttrlike the runtime does.The new
stringifyStatic.spec.tscases fail without the change.vitest runfor compiler-dom/core/sfc and server-renderer (1651 tests),tsc --noEmit, ESLint and Prettier pass.Summary by CodeRabbit
disabled,checked, andhidden, when their bound values are false.