#8331 Maximize browser compatibility

This commit is contained in:
mathieu-mp 2022-02-04 18:08:58 +01:00 committed by thatmattlove
parent 5b985a924b
commit 60f48326e1
3 changed files with 7 additions and 7 deletions

View File

@ -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<HTMLSelectElement>(`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.

View File

@ -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');
}
}

View File

@ -315,7 +315,7 @@ export function* getRowValues(table: HTMLTableRowElement): Generator<string> {
for (const element of table.querySelectorAll<HTMLTableCellElement>('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();
}
}
}