From 57d407d0ebcbeeceacb6a26d693e27fa4e280065 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Tue, 16 Apr 2024 12:29:37 +0100 Subject: [PATCH] Use template literals for names in selectors --- client/src/entrypoints/admin/telepath/widgets.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/client/src/entrypoints/admin/telepath/widgets.js b/client/src/entrypoints/admin/telepath/widgets.js index 201e0f8bd5..0604dbab05 100644 --- a/client/src/entrypoints/admin/telepath/widgets.js +++ b/client/src/entrypoints/admin/telepath/widgets.js @@ -9,7 +9,7 @@ class BoundWidget { parentCapabilities, options, ) { - var selector = ':is(input,select,textarea,button)[name="' + name + '"]'; + const selector = `:is(input,select,textarea,button)[name="${name}"]`; // find, including element itself this.input = element.matches(selector) ? element @@ -129,7 +129,7 @@ class BoundRadioSelect { this.element = element; this.name = name; this.idForLabel = idForLabel; - this.selector = 'input[name="' + name + '"]:checked'; + this.selector = `input[name="${name}"]:checked`; this.setState(initialState); } @@ -142,16 +142,14 @@ class BoundRadioSelect { } setState(state) { - const inputs = this.element.querySelectorAll( - 'input[name="' + this.name + '"]', - ); + const inputs = this.element.querySelectorAll(`input[name="${this.name}"]`); for (let i = 0; i < inputs.length; i += 1) { inputs[i].checked = inputs[i].value === state; } } focus() { - this.element.querySelector('input[name="' + this.name + '"]')?.focus(); + this.element.querySelector(`input[name="${this.name}"]`)?.focus(); } }