- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 8.6k
 
[js] [atoms] Fixed text transformation issue with text-transform: capitalize #16275
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
          PR Reviewer Guide 🔍Here are some key observations to aid the review process: 
  | 
    
          PR Code Suggestions ✨Explore these optional code suggestions: 
  | 
    ||||||||||||
| // Preceded by start or a non-word (so it won't fire for snake_case) | ||
| re = /(^|[^'_0-9A-Za-z\u00C0-\u02AF\u1E00-\u1EFF\u24B6-\u24E9])([_*])([A-Za-z\u00C0-\u02AF\u1E00-\u1EFF\u24D0-\u24E9])/g; | ||
| text = text.replace(re, function () { | ||
| return arguments[1] + arguments[2] + arguments[3].toUpperCase(); | 
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.
Here you can remove the magic numbers and leave something more descriptive like:
    text = text.replace(re, function (_match, prefix, divider, char) {
      return prefix + divider + char.toUpperCase();
    });
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.
Sure, I just followed the existing implementation and coding style
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.
No worries, it's just a coding tip.
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.
Thank you, @vicky-iv!
User description
🔗 Related Issues
Fixes #14271
💥 What does this PR do?
Fixes incorrect capitalization behavior for text-transform: capitalize, addressing:
🔧 Implementation Notes
Replaced the previous boundary regex:
First step uses a negated “separator” class that treats ASCII letters, extended Latin letters (\u00C0–\u02AF, \u1E00–\u1EFF) and combining marks (\u0300–\u036F, \u1AB0–\u1AFF, \u1DC0–\u1DFF) as in-word characters, and excludes _ and apostrophes from being boundaries (so we don’t split snake_case or contractions).
Second step: a small second regex capitalizes the first letter after an opening _ or * only when those symbols act as wrappers (preceded by start or a non-word), avoiding interference with snake_case.
All tests from the text_test.html are passed locally:
💡 Additional Considerations
Scope limited to Latin scripts + circled letters; other scripts (Greek/Cyrillic/etc.) can be added by extending ranges if needed.
🔄 Types of changes
PR Type
Bug fix
Description
Fixed text-transform: capitalize for accented Latin letters
Added support for enye and extended Unicode ranges
Improved boundary detection to preserve snake_case
Added test cases for Spanish accented characters
Diagram Walkthrough
File Walkthrough
dom.js
Enhanced text capitalization with Unicode supportjavascript/atoms/dom.js
text_test.html
Added Unicode capitalization test casesjavascript/atoms/test/text_test.html