fix(web-components): make TextInput spellcheck null-safe - #36482
Draft
AKnassa wants to merge 1 commit into
Draft
Conversation
The TextInput spellcheck attribute converter's toView called value.toString() unconditionally. fast-element runs fromView for property writes too, so any non-string write (el.spellcheck = true, false, null, or undefined) stored null and the queued attribute reflection crashed with 'Cannot read properties of null'. Removing the attribute also left the field null, silently swallowing all later boolean writes. Handle booleans in fromView so property writes round-trip, and return null from toView for nullish values so the attribute is removed instead of throwing. Attribute-driven behavior (including spellcheck="false" on the internal control) is unchanged. Adds spec coverage for both attribute values, boolean property reflection, null removal, and post-removal property writes. Fixes microsoft#36462
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.
Previous Behavior
Setting the
spellcheckproperty on<fluent-text-input>from JavaScript crashed the page withTypeError: Cannot read properties of null (reading 'toString'). This hit anyone using frameworks that set properties instead of attributes (React 19, Angular, Lit). On top of that, removing thespellcheckattribute silently broke the property forever — later writes just did nothing.New Behavior
spellcheckworks like you'd expect in every direction: set it totrue/falsefrom JS and the attribute reflects correctly, set it tonulland the attribute is removed, remove the attribute and the property still works afterwards. Plain attribute usage (spellcheck="false"in HTML) behaves exactly as before.What changed
text-input.base.tsnow handles booleans and null instead of assuming it always gets a string.How to verify
Before this fix, this one-liner crashes the page; now it works:
Related Issue(s)