Conversation
…erer
When a template attribute has the FAST boolean binding prefix `?`
the attribute as `?disabled=""` instead of evaluating the expression.
Fix: in `resolve_attribute_bindings_in_tag`, detect the `?name="{{expr}}"`
pattern by checking whether the accumulated output ends with `?name="`
before a `{{` is found. When detected:
- Evaluate the expression as a boolean using the existing `expression::evaluate`
- If truthy: emit the bare attribute name (e.g. `disabled`)
- If falsy: emit nothing (attribute is omitted)
Add six hydration tests covering true/false cases for simple boolean
Co-authored-by: Copilot <[email protected]>
- README.md: add 'Boolean Attribute Bindings' section under Template Syntax
explaining the ?attr="{{expr}}" convention and its rendered output
- README.md: update attribute binding markers example to include ?attr cases
- DESIGN.md: expand step 3 of 'Attribute binding markers' to describe the
three resolution strategies: boolean (?attr), value ({{expr}}), and
single-brace passthrough ({expr})
Co-authored-by: Copilot <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request
📖 Description
Before:
<input ?disabled="" data-fe-c-0-1>After (truthy):
<input disabled data-fe-c-0-1>After (falsy):
<input data-fe-c-0-1>Root cause:
resolve_attribute_bindings_in_taginattribute.rswas treating all{{expr}}attribute values as string replacements. It had no awareness of the?prefix convention used by FAST to mark boolean attributes.Fix: Before replacing a
{{expr}}binding, the function now checks whether the accumulated output ends with?name="— indicating a boolean binding. If so, it:?name="prefix from the outputexpression::evaluate📑 Test Plan
Six new tests were added to
tests/hydration.rscovering:?attr="{{expr}}"with a truthy value → bare attribute rendered?attr="{{expr}}"with a falsy value → attribute omitted?disabled="{{a == b}}"(both matching and non-matching)All 127 Rust tests pass (
cargo testincrates/microsoft-fast-build).✅ Checklist
General
$ npm run change⏭ Next Steps
The WASM artifacts in
packages/fast-build/wasm/need to be rebuilt from this crate fix (npm run build:wasm -w @microsoft/fast-build) before the fix is available to JavaScript consumers.