From e9b729fc46f88b666c80ca9123f0e6926e076fbb Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Mon, 25 Mar 2024 01:50:39 +0200 Subject: [PATCH] Remove jQuery `.attr` from the label edit exclusive checkbox (#30053) - Switched from jQuery `attr` to plain javascript `getAttribute` - Tested the label edit exclusive checkbox and it works as before Signed-off-by: Yarden Shoham (cherry picked from commit a7d0c5de4c82d8d206f6c5c51f012ee831502f67) --- web_src/js/features/comp/LabelEdit.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/web_src/js/features/comp/LabelEdit.js b/web_src/js/features/comp/LabelEdit.js index c5992fa355..843657a6b6 100644 --- a/web_src/js/features/comp/LabelEdit.js +++ b/web_src/js/features/comp/LabelEdit.js @@ -6,23 +6,23 @@ function isExclusiveScopeName(name) { } function updateExclusiveLabelEdit(form) { - const $nameInput = $(`${form} .label-name-input`); - const $exclusiveField = $(`${form} .label-exclusive-input-field`); - const $exclusiveCheckbox = $(`${form} .label-exclusive-input`); - const $exclusiveWarning = $(`${form} .label-exclusive-warning`); + const nameInput = document.querySelector(`${form} .label-name-input`); + const exclusiveField = document.querySelector(`${form} .label-exclusive-input-field`); + const exclusiveCheckbox = document.querySelector(`${form} .label-exclusive-input`); + const exclusiveWarning = document.querySelector(`${form} .label-exclusive-warning`); - if (isExclusiveScopeName($nameInput.val())) { - $exclusiveField.removeClass('muted'); - $exclusiveField.removeAttr('aria-disabled'); - if ($exclusiveCheckbox[0].checked && $exclusiveCheckbox.data('exclusive-warn')) { - $exclusiveWarning.removeClass('tw-hidden'); + if (isExclusiveScopeName(nameInput.value)) { + exclusiveField?.classList.remove('muted'); + exclusiveField?.removeAttribute('aria-disabled'); + if (exclusiveCheckbox.checked && exclusiveCheckbox.getAttribute('data-exclusive-warn')) { + exclusiveWarning?.classList.remove('tw-hidden'); } else { - $exclusiveWarning.addClass('tw-hidden'); + exclusiveWarning?.classList.add('tw-hidden'); } } else { - $exclusiveField.addClass('muted'); - $exclusiveField.attr('aria-disabled', 'true'); - $exclusiveWarning.addClass('tw-hidden'); + exclusiveField?.classList.add('muted'); + exclusiveField?.setAttribute('aria-disabled', 'true'); + exclusiveWarning?.classList.add('tw-hidden'); } }