From 60f48326e19fe65529e1dcbd56fc868c0bf41027 Mon Sep 17 00:00:00 2001 From: mathieu-mp Date: Fri, 4 Feb 2022 18:08:58 +0100 Subject: [PATCH] #8331 Maximize browser compatibility --- netbox/project-static/src/select/api/apiSelect.ts | 8 ++++---- netbox/project-static/src/tables/interfaceTable.ts | 4 ++-- netbox/project-static/src/util.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/netbox/project-static/src/select/api/apiSelect.ts b/netbox/project-static/src/select/api/apiSelect.ts index f24c3fa5b..e12a10421 100644 --- a/netbox/project-static/src/select/api/apiSelect.ts +++ b/netbox/project-static/src/select/api/apiSelect.ts @@ -461,7 +461,7 @@ export class APISelect { // Set any primitive k/v pairs as data attributes on each option. for (const [k, v] of Object.entries(result)) { if (!['id', 'slug'].includes(k) && ['string', 'number', 'boolean'].includes(typeof v)) { - const key = k.replaceAll('_', '-'); + const key = k.replace(/_/g, '-'); data[key] = String(v); } // Set option to disabled if the result contains a matching key and is truthy. @@ -659,7 +659,7 @@ export class APISelect { for (const [key, value] of this.pathValues.entries()) { for (const result of this.url.matchAll(new RegExp(`({{${key}}})`, 'g'))) { if (isTruthy(value)) { - url = url.replaceAll(result[1], value.toString()); + url = url.replace(result[1], value.toString()); } } } @@ -741,7 +741,7 @@ export class APISelect { * @param id DOM ID of the other element. */ private updatePathValues(id: string): void { - const key = id.replaceAll(/^id_/gi, ''); + const key = id.replace(/^id_/gi, ''); const element = getElement(`id_${key}`); if (element !== null) { // If this element's URL contains Django template tags ({{), replace the template tag @@ -927,7 +927,7 @@ export class APISelect { color: ${fg} !important; } ` - .replaceAll('\n', '') + .replace(/\n/g, '') .trim(); // Add the style element to the DOM. diff --git a/netbox/project-static/src/tables/interfaceTable.ts b/netbox/project-static/src/tables/interfaceTable.ts index 0f7f985aa..6937a82e8 100644 --- a/netbox/project-static/src/tables/interfaceTable.ts +++ b/netbox/project-static/src/tables/interfaceTable.ts @@ -105,9 +105,9 @@ class ButtonState { */ private toggleButton(): void { if (this.buttonState === 'show') { - this.button.innerText = this.button.innerText.replaceAll('Show', 'Hide'); + this.button.innerText = this.button.innerText.replace(/Show/g, 'Hide'); } else if (this.buttonState === 'hide') { - this.button.innerText = this.button.innerText.replaceAll('Hide', 'Show'); + this.button.innerText = this.button.innerText.replace(/Hide/g, 'Show'); } } diff --git a/netbox/project-static/src/util.ts b/netbox/project-static/src/util.ts index 04dfa1d01..d85f9fbf9 100644 --- a/netbox/project-static/src/util.ts +++ b/netbox/project-static/src/util.ts @@ -315,7 +315,7 @@ export function* getRowValues(table: HTMLTableRowElement): Generator { for (const element of table.querySelectorAll('td')) { if (element !== null) { if (isTruthy(element.innerText) && element.innerText !== '—') { - yield element.innerText.replaceAll(/[\n\r]/g, '').trim(); + yield element.innerText.replace(/[\n\r]/g, '').trim(); } } }