From 33c6b7841a59aaaad55744909c0600f066fd5593 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Wed, 10 Apr 2024 14:02:39 +0200 Subject: [PATCH] Fixing atom to capitalize text (#13792) * Fixing atom to capitalize text Credit to @whimboo Fixes #13779 * Adding a test --- javascript/atoms/dom.js | 2 +- javascript/atoms/test/text_test.html | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/javascript/atoms/dom.js b/javascript/atoms/dom.js index 6a46cff410fe5..1f521f06a99a5 100644 --- a/javascript/atoms/dom.js +++ b/javascript/atoms/dom.js @@ -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(); }); diff --git a/javascript/atoms/test/text_test.html b/javascript/atoms/test/text_test.html index 14f40c53b4d59..5620902711039 100644 --- a/javascript/atoms/test/text_test.html +++ b/javascript/atoms/test/text_test.html @@ -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) { @@ -430,6 +432,7 @@ ⓐⓑⓒ (ⓓⓔⓕ) —ⓖⓗⓘ— ⓙkl
(this) “is” [a] –short– -test- «for» *the* _css_ ¿capitalize? ?¡transfor
The Dutch word: "ijsland" starts with a digraph
+ test_text