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:
@@ -921,7 +921,7 @@ function sliderValueRange(e, direction) {
|
|||||||
// Update the slider
|
// Update the slider
|
||||||
selectArea.value = closestIndexes;
|
selectArea.value = closestIndexes;
|
||||||
// Reset the start/end calendar selection range
|
// Reset the start/end calendar selection range
|
||||||
if (!isDateType) inputValue = Number(e.value.replace(/,/g, ""));
|
if (!isDateType) inputValue = Number(e.value.replaceAll(",", ""));
|
||||||
if (direction === "start") {
|
if (direction === "start") {
|
||||||
if (isDateType) {
|
if (isDateType) {
|
||||||
endMinDate.value = e;
|
endMinDate.value = e;
|
||||||
|
|||||||
@@ -523,7 +523,7 @@ function switchTab(newTab) {
|
|||||||
function timeLabel(time) {
|
function timeLabel(time) {
|
||||||
// sonar-qube prevent super-linear runtime due to backtracking; change * to ?
|
// sonar-qube prevent super-linear runtime due to backtracking; change * to ?
|
||||||
//
|
//
|
||||||
const label = getTimeLabel(time).replace(/\s+/g, " "); // Collapse all consecutive whitespace into a single space
|
const label = getTimeLabel(time).replaceAll(/\s+/g, " "); // Collapse all consecutive whitespace into a single space
|
||||||
const result = label.match(/^([\d.]+)\s?([a-zA-Z]+)$/); // add ^ and $ to meet sonar-qube need
|
const result = label.match(/^([\d.]+)\s?([a-zA-Z]+)$/); // add ^ and $ to meet sonar-qube need
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ function onChange(event) {
|
|||||||
* @param {KeyboardEvent} event - The keyup event.
|
* @param {KeyboardEvent} event - The keyup event.
|
||||||
*/
|
*/
|
||||||
function onKeyUp(event) {
|
function onKeyUp(event) {
|
||||||
event.target.value = event.target.value.replace(/\D/g, "");
|
event.target.value = event.target.value.replaceAll(/\D/g, "");
|
||||||
if (event.keyCode === 38 || event.keyCode === 40) {
|
if (event.keyCode === 38 || event.keyCode === 40) {
|
||||||
actionUpDown(event.target, event.keyCode === 38, true);
|
actionUpDown(event.target, event.keyCode === 38, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
*/
|
*/
|
||||||
export function escapeHtml(str) {
|
export function escapeHtml(str) {
|
||||||
return str
|
return str
|
||||||
.replace(/&/g, "&")
|
.replaceAll("&", "&")
|
||||||
.replace(/</g, "<")
|
.replaceAll("<", "<")
|
||||||
.replace(/>/g, ">")
|
.replaceAll(">", ">")
|
||||||
.replace(/"/g, """)
|
.replaceAll('"', """)
|
||||||
.replace(/'/g, "'");
|
.replaceAll("'", "'");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ function onInput(e) {
|
|||||||
*/
|
*/
|
||||||
function getTextWidth(text, e) {
|
function getTextWidth(text, e) {
|
||||||
// Replace spaces with non-breaking spaces
|
// Replace spaces with non-breaking spaces
|
||||||
const processedText = text.replace(/ /g, "\u00a0");
|
const processedText = text.replaceAll(" ", "\u00a0");
|
||||||
const hiddenSpan = document.createElement("span");
|
const hiddenSpan = document.createElement("span");
|
||||||
|
|
||||||
hiddenSpan.textContent = processedText;
|
hiddenSpan.textContent = processedText;
|
||||||
|
|||||||
Reference in New Issue
Block a user