Use String.replaceAll() instead of String.replace() with /g flag (S7781)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 00:29:28 +08:00
parent 2b0dadedd4
commit ebd198e28d
5 changed files with 9 additions and 9 deletions

View File

@@ -325,7 +325,7 @@ function onInput(e) {
*/
function getTextWidth(text, e) {
// Replace spaces with non-breaking spaces
const processedText = text.replace(/ /g, "\u00a0");
const processedText = text.replaceAll(" ", "\u00a0");
const hiddenSpan = document.createElement("span");
hiddenSpan.textContent = processedText;