From 8d71b733ad44bdeaaa01380906bd00151ed4bde6 Mon Sep 17 00:00:00 2001 From: jackHay22 Date: Fri, 17 Jan 2025 13:50:11 -0500 Subject: [PATCH] fix lints --- web_src/js/features/repo-release.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/web_src/js/features/repo-release.ts b/web_src/js/features/repo-release.ts index f0d8ceebb3b..75afeb238e2 100644 --- a/web_src/js/features/repo-release.ts +++ b/web_src/js/features/repo-release.ts @@ -1,3 +1,4 @@ +import $ from 'jquery'; import {hideElem, showElem, type DOMEvent} from '../utils/dom.ts'; import {fomanticQuery} from '../modules/fomantic/base.ts'; @@ -23,7 +24,7 @@ function initTagNameEditor() { if (!el) return; const tagWarning = document.querySelector('#tag-warning'); - const tagWarningDetailLinks = Array.from(document.getElementsByClassName('tag-warning-detail')); + const tagWarningDetailLinks = Array.from(document.querySelectorAll('.tag-warning-detail')); const existingTags = JSON.parse(el.getAttribute('data-existing-tags')); const defaultTagHelperText = el.getAttribute('data-tag-helper'); @@ -38,23 +39,24 @@ function initTagNameEditor() { $('.tag-confirm').on('click', (event) => { if (requiresConfirmation) { event.preventDefault(); - if ($(event.target).hasClass('tag-draft')) { + const form = event.target.closest('form'); + if (event.target.classList.contains('tag-draft')) { fomanticQuery(tagConfirmDraftModal).modal({ onApprove() { // need to add hidden input with draft form value // (triggering form submission doesn't include the button data) - $('').attr({ - type: 'hidden', - name: 'draft', - value: '1' - }).appendTo(event.target.form); - $(event.target.form).trigger('submit'); + const input = document.createElement('input'); + input.type = 'hidden'; + input.name = 'draft'; + input.value = '1'; + form.append(input); + $(form).trigger('submit'); }, }).modal('show'); } else { fomanticQuery(tagConfirmModal).modal({ onApprove() { - $(event.target.form).trigger('submit'); + $(form).trigger('submit'); }, }).modal('show'); } @@ -71,8 +73,9 @@ function initTagNameEditor() { tagHelper.textContent = existingTagHelperText; showElem('#tag-warning'); for (const detail of tagWarningDetailLinks) { - detail.href = `${tagURLStub}/${existingTags[value]}`; - detail.textContent = existingTags[value].substring(0, 10); + const anchor = detail as HTMLAnchorElement; + anchor.href = `${tagURLStub}/${existingTags[value]}`; + anchor.textContent = existingTags[value].substring(0, 10); } requiresConfirmation = true; } else {