diff --git a/javascript/atoms/dom.js b/javascript/atoms/dom.js index 196412d3cb18d..d21987649e359 100644 --- a/javascript/atoms/dom.js +++ b/javascript/atoms/dom.js @@ -1176,8 +1176,8 @@ bot.dom.appendVisibleTextLinesFromTextNode_ = function(textNode, lines, } if (textTransform == 'capitalize') { - text = text.replace(/(^|\s)(\S)/g, function() { - return arguments[1] + arguments[2].toUpperCase(); + text = text.replace(/\b(\S)/g, function() { + return arguments[1].toUpperCase(); }); } else if (textTransform == 'uppercase') { text = text.toUpperCase(); diff --git a/javascript/atoms/test/text_test.html b/javascript/atoms/test/text_test.html index 2b8e2251bb772..4698ac5db46db 100644 --- a/javascript/atoms/test/text_test.html +++ b/javascript/atoms/test/text_test.html @@ -257,7 +257,7 @@ function testGetVisibleTextShouldHandleTextTransformProperty() { var text = getVisibleTextByElementId("capitalized"); - assertEquals("Hello, World! Bla-bla-BLA", text); + assertEquals("Hello, World! Bla-Bla-BLA", text); text = getVisibleTextByElementId("lowercased"); assertEquals("hello, world! bla-bla-bla", text); text = getVisibleTextByElementId("uppercased"); @@ -398,9 +398,9 @@ This line has a bunch of ze​ro-width‎ characters‏ in it.
- Hello, world! bla-bla-BLA
+ hello, world! bla-bla-BLA
Hello, world! bla-bla-BLA
- Hello, world! bla-bla-BLA
+ hello, world! bla-bla-BLA