Skip to content

Commit

Permalink
Fixing atom to capitalize text (#13792)
Browse files Browse the repository at this point in the history
* Fixing atom to capitalize text

Credit to @whimboo

Fixes #13779

* Adding a test
  • Loading branch information
diemol authored Apr 10, 2024
1 parent d142ce0 commit 33c6b78
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion javascript/atoms/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ bot.dom.appendVisibleTextLinesFromTextNode_ = function(textNode, lines,

if (textTransform == 'capitalize') {
// the unicode regex ending with /gu does not work in IE
var re = goog.userAgent.IE ? /(^|\s|\b)(\S)/g : /(^|[^\d\p{L}\p{S}])([\p{Ll}|\p{S}])/gu;
var re = goog.userAgent.IE ? /(^|\s|\b)(\S)/g : /(^|\s|\b)(\S)/gu;
text = text.replace(re, function() {
return arguments[1] + arguments[2].toUpperCase();
});
Expand Down
3 changes: 3 additions & 0 deletions javascript/atoms/test/text_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@
assertEquals('(This) “Is” [A] –Short– -Test- «For» *The* _Css_ ¿Capitalize? ?¡Transfor', text);
text = getVisibleTextByElementId("capitalized-8");
assertEquals('The Dutch Word: "Ijsland" Starts With A Digraph', text);
text = getVisibleTextByElementId("capitalized-9");
assertEquals('Test_text', text);
}

function getVisibleTextByElementId(id) {
Expand Down Expand Up @@ -430,6 +432,7 @@
<a id="capitalized-6" style="text-transform: capitalize">ⓐⓑⓒ (ⓓⓔⓕ) —ⓖⓗⓘ— ⓙkl</a><br/>
<a id="capitalized-7" style="text-transform: capitalize">(this) “is” [a] –short– -test- «for» *the* _css_ ¿capitalize? ?¡transfor</a><br/>
<a id="capitalized-8" style="text-transform: capitalize">The Dutch word: "ijsland" starts with a digraph</a><br/>
<a id="capitalized-9" style="text-transform: capitalize">test_text</a><br/>
</div>

</body>
Expand Down

0 comments on commit 33c6b78

Please sign in to comment.