0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-25 05:02:57 +01:00

Use template literals for names in selectors

This commit is contained in:
Matt Westcott 2024-04-16 12:29:37 +01:00 committed by Sage Abdullah
parent 9b74c83195
commit 57d407d0eb
No known key found for this signature in database
GPG Key ID: EB1A33CC51CC0217

View File

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