summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2024-03-24 18:56:02 +0100
committerGitHub <noreply@github.com>2024-03-24 17:56:02 +0000
commit0a2f973de9b681a472c96bdfcd945978e88458d8 (patch)
tree4df05bf0d064a53a670cd03ccd67dc61b59234e7
parent8d93cea2969730fc8f3bdeb3704a3b89db0bbcc0 (diff)
downloadgitea-0a2f973de9b681a472c96bdfcd945978e88458d8.tar.gz
gitea-0a2f973de9b681a472c96bdfcd945978e88458d8.zip
Forbid jQuery `is` and fix issues (#30016)
Tested all functionality. --------- Co-authored-by: Yarden Shoham <git@yardenshoham.com>
-rw-r--r--.eslintrc.yaml4
-rw-r--r--web_src/js/features/admin/common.js4
-rw-r--r--web_src/js/features/common-global.js2
-rw-r--r--web_src/js/features/repo-legacy.js6
-rw-r--r--web_src/js/modules/fomantic/dropdown.js2
5 files changed, 9 insertions, 9 deletions
diff --git a/.eslintrc.yaml b/.eslintrc.yaml
index eeb3e20cb8..ea14d27d4c 100644
--- a/.eslintrc.yaml
+++ b/.eslintrc.yaml
@@ -303,7 +303,7 @@ rules:
jquery/no-in-array: [2]
jquery/no-is-array: [2]
jquery/no-is-function: [2]
- jquery/no-is: [0]
+ jquery/no-is: [2]
jquery/no-load: [2]
jquery/no-map: [2]
jquery/no-merge: [2]
@@ -440,7 +440,7 @@ rules:
no-jquery/no-is-numeric: [2]
no-jquery/no-is-plain-object: [2]
no-jquery/no-is-window: [2]
- no-jquery/no-is: [0]
+ no-jquery/no-is: [2]
no-jquery/no-jquery-constructor: [0]
no-jquery/no-live: [2]
no-jquery/no-load-shorthand: [2]
diff --git a/web_src/js/features/admin/common.js b/web_src/js/features/admin/common.js
index 0c65f04ab8..3c485d67a6 100644
--- a/web_src/js/features/admin/common.js
+++ b/web_src/js/features/admin/common.js
@@ -84,7 +84,7 @@ export function initAdminCommon() {
hideElem($('.oauth2_use_custom_url_field'));
$('.oauth2_use_custom_url_field input[required]').removeAttr('required');
- if ($('#oauth2_use_custom_url').is(':checked')) {
+ if (document.getElementById('oauth2_use_custom_url')?.checked) {
for (const custom of ['token_url', 'auth_url', 'profile_url', 'email_url', 'tenant']) {
if (applyDefaultValues) {
$(`#oauth2_${custom}`).val($(`#${provider}_${custom}`).val());
@@ -98,7 +98,7 @@ export function initAdminCommon() {
}
function onEnableLdapGroupsChange() {
- toggleElem($('#ldap-group-options'), $('.js-ldap-group-toggle').is(':checked'));
+ toggleElem($('#ldap-group-options'), $('.js-ldap-group-toggle')[0].checked);
}
// New authentication
diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js
index e27935a86e..e2ce01eb49 100644
--- a/web_src/js/features/common-global.js
+++ b/web_src/js/features/common-global.js
@@ -373,7 +373,7 @@ function initGlobalShowModal() {
if (attrTargetAttr) {
$attrTarget[0][attrTargetAttr] = attrib.value;
- } else if ($attrTarget.is('input') || $attrTarget.is('textarea')) {
+ } else if ($attrTarget[0].matches('input, textarea')) {
$attrTarget.val(attrib.value); // FIXME: add more supports like checkbox
} else {
$attrTarget.text(attrib.value); // FIXME: it should be more strict here, only handle div/span/p
diff --git a/web_src/js/features/repo-legacy.js b/web_src/js/features/repo-legacy.js
index 43567f4393..838540fcc0 100644
--- a/web_src/js/features/repo-legacy.js
+++ b/web_src/js/features/repo-legacy.js
@@ -139,7 +139,7 @@ export function initRepoCommentForm() {
hasUpdateAction = $listMenu.data('action') === 'update'; // Update the var
- const $clickedItem = $(this);
+ const clickedItem = this; // eslint-disable-line unicorn/no-this-assignment
const scope = $(this).attr('data-scope');
$(this).parent().find('.item').each(function () {
@@ -148,10 +148,10 @@ export function initRepoCommentForm() {
if ($(this).attr('data-scope') !== scope) {
return true;
}
- if (!$(this).is($clickedItem) && !$(this).hasClass('checked')) {
+ if (this !== clickedItem && !$(this).hasClass('checked')) {
return true;
}
- } else if (!$(this).is($clickedItem)) {
+ } else if (this !== clickedItem) {
// Toggle for other labels
return true;
}
diff --git a/web_src/js/modules/fomantic/dropdown.js b/web_src/js/modules/fomantic/dropdown.js
index 7302078dbd..97aabb44b6 100644
--- a/web_src/js/modules/fomantic/dropdown.js
+++ b/web_src/js/modules/fomantic/dropdown.js
@@ -199,7 +199,7 @@ function attachDomEvents($dropdown, $focusable, $menu) {
if (!$item) $item = $menu.find('> .item.selected'); // when dropdown filters items by input, there is no "value", so query the "selected" item
// if the selected item is clickable, then trigger the click event.
// we can not click any item without check, because Fomantic code might also handle the Enter event. that would result in double click.
- if ($item && ($item.is('a') || $item.hasClass('js-aria-clickable'))) $item[0].click();
+ if ($item && ($item[0].matches('a') || $item.hasClass('js-aria-clickable'))) $item[0].click();
}
});