-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Update FieldIdGenerator to support HTML5 instead of HTML 4.01 #65058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Remove HTML 4.01 first-character-must-be-letter rule - Simplify to only replace whitespace and periods with underscores - Update documentation to reference HTML5 instead of HTML 4.01 - Remove redundant SearchValues and helper methods - Update tests to reflect HTML5 behavior (no prepending 'z', brackets allowed) - Remove "Arrange Act Assert" comments from all unit tests Co-authored-by: ilonatommy <[email protected]>
- Use IndexOfAny for more efficient fast-path check - Add test for various whitespace characters (tab, newline, carriage return) Co-authored-by: ilonatommy <[email protected]>
- Combine whitespace tests into one - Remove redundant Fact tests (already covered by Theory test) - Remove duplicate InlineData entries Co-authored-by: ilonatommy <[email protected]>
- Convert standalone Fact test to InlineData in Theory test - Further streamlines test structure Co-authored-by: ilonatommy <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates FieldIdGenerator to support HTML5 ID attribute rules instead of HTML 4.01, simplifying the validation logic and reducing code complexity.
Changes:
- Removed HTML 4.01 restrictions (first character must be a letter) to allow any non-whitespace characters
- Simplified character validation to only replace whitespace and periods with underscores
- Consolidated test cases into a single Theory test method with InlineData attributes
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Components/Web/src/Forms/FieldIdGenerator.cs | Updated to HTML5 rules: removed first-character validation, simplified character replacement logic, removed SearchValues dependency |
| src/Components/Web/test/Forms/FieldIdGeneratorTest.cs | Consolidated tests into single Theory method, removed AAA comments, updated test cases to reflect HTML5 behavior |
- Add SearchValues with all Unicode whitespace characters and period - Ensures fast path catches all whitespace cases consistently - Add test for non-breaking space (U+00A0) Co-authored-by: ilonatommy <[email protected]>
Head branch was pushed to by a user without write access
- Use InvalidIdChars.Contains() in slow path for consistency - Ensures both paths validate the same set of characters Co-authored-by: ilonatommy <[email protected]>
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.