Skip to content

Commit 5ff9c8e

Browse files
committed
Forbide jQuery .prop and fix related issues
1 parent 6ead30d commit 5ff9c8e

File tree

5 files changed

+31
-23
lines changed

5 files changed

+31
-23
lines changed

.eslintrc.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ rules:
315315
jquery/no-parent: [0]
316316
jquery/no-parents: [0]
317317
jquery/no-parse-html: [2]
318-
jquery/no-prop: [0]
318+
jquery/no-prop: [2]
319319
jquery/no-proxy: [2]
320320
jquery/no-ready: [2]
321321
jquery/no-serialize: [2]
@@ -466,7 +466,7 @@ rules:
466466
no-jquery/no-parse-html: [2]
467467
no-jquery/no-parse-json: [2]
468468
no-jquery/no-parse-xml: [2]
469-
no-jquery/no-prop: [0]
469+
no-jquery/no-prop: [2]
470470
no-jquery/no-proxy: [2]
471471
no-jquery/no-ready-shorthand: [2]
472472
no-jquery/no-ready: [2]

web_src/js/features/admin/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function initAdminCommon() {
4949
}
5050

5151
function onUsePagedSearchChange() {
52-
if ($('#use_paged_search').prop('checked')) {
52+
if (document.getElementById('use_paged_search').checked) {
5353
showElem('.search-page-size');
5454
$('.search-page-size').find('input').attr('required', 'required');
5555
} else {

web_src/js/features/repo-editor.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ export function initRepoEditor() {
6767
$('.js-quick-pull-choice-option').on('change', function () {
6868
if ($(this).val() === 'commit-to-new-branch') {
6969
showElem($('.quick-pull-branch-name'));
70-
$('.quick-pull-branch-name input').prop('required', true);
70+
document.querySelector('.quick-pull-branch-name input').required = true;
7171
} else {
7272
hideElem($('.quick-pull-branch-name'));
73-
$('.quick-pull-branch-name input').prop('required', false);
73+
document.querySelector('.quick-pull-branch-name input').required = false;
7474
}
7575
$('#commit-button').text($(this).attr('button_text'));
7676
});
@@ -135,13 +135,13 @@ export function initRepoEditor() {
135135

136136
// Using events from https://github.com/codedance/jquery.AreYouSure#advanced-usage
137137
// to enable or disable the commit button
138-
const $commitButton = $('#commit-button');
138+
const commitButton = document.getElementById('commit-button');
139139
const $editForm = $('.ui.edit.form');
140140
const dirtyFileClass = 'dirty-file';
141141

142142
// Disabling the button at the start
143143
if ($('input[name="page_has_posted"]').val() !== 'true') {
144-
$commitButton.prop('disabled', true);
144+
commitButton.disabled = true;
145145
}
146146

147147
// Registering a custom listener for the file path and the file content
@@ -151,7 +151,7 @@ export function initRepoEditor() {
151151
fieldSelector: ':input:not(.commit-form-wrapper :input)',
152152
change() {
153153
const dirty = $(this).hasClass(dirtyFileClass);
154-
$commitButton.prop('disabled', !dirty);
154+
commitButton.disabled = !dirty;
155155
},
156156
});
157157

@@ -163,15 +163,15 @@ export function initRepoEditor() {
163163
editor.setValue(value);
164164
}
165165

166-
$commitButton.on('click', (event) => {
166+
commitButton?.addEventListener('click', (e) => {
167167
// A modal which asks if an empty file should be committed
168168
if ($editArea.val().length === 0) {
169169
$('#edit-empty-content-modal').modal({
170170
onApprove() {
171171
$('.edit.form').trigger('submit');
172172
},
173173
}).modal('show');
174-
event.preventDefault();
174+
e.preventDefault();
175175
}
176176
});
177177
})();

web_src/js/features/repo-issue-list.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,40 @@ import {createSortable} from '../modules/sortable.js';
88
import {DELETE, POST} from '../modules/fetch.js';
99

1010
function initRepoIssueListCheckboxes() {
11-
const $issueSelectAll = $('.issue-checkbox-all');
12-
const $issueCheckboxes = $('.issue-checkbox');
11+
const issueSelectAll = document.querySelector('.issue-checkbox-all');
12+
const issueCheckboxes = document.querySelectorAll('.issue-checkbox');
1313

1414
const syncIssueSelectionState = () => {
15-
const $checked = $issueCheckboxes.filter(':checked');
16-
const anyChecked = $checked.length !== 0;
17-
const allChecked = anyChecked && $checked.length === $issueCheckboxes.length;
15+
const checkedCheckboxes = Array.from(issueCheckboxes).filter((el) => el.checked);
16+
const anyChecked = Boolean(checkedCheckboxes.length);
17+
const allChecked = anyChecked && checkedCheckboxes.length === issueCheckboxes.length;
1818

1919
if (allChecked) {
20-
$issueSelectAll.prop({'checked': true, 'indeterminate': false});
20+
issueSelectAll.checked = true;
21+
issueSelectAll.indeterminate = false;
2122
} else if (anyChecked) {
22-
$issueSelectAll.prop({'checked': false, 'indeterminate': true});
23+
issueSelectAll.checked = false;
24+
issueSelectAll.indeterminate = true;
2325
} else {
24-
$issueSelectAll.prop({'checked': false, 'indeterminate': false});
26+
issueSelectAll.checked = false;
27+
issueSelectAll.indeterminate = false;
2528
}
2629
// if any issue is selected, show the action panel, otherwise show the filter panel
2730
toggleElem($('#issue-filters'), !anyChecked);
2831
toggleElem($('#issue-actions'), anyChecked);
2932
// there are two panels but only one select-all checkbox, so move the checkbox to the visible panel
30-
$('#issue-filters, #issue-actions').filter(':visible').find('.issue-list-toolbar-left').prepend($issueSelectAll);
33+
$('#issue-filters, #issue-actions').filter(':visible').find('.issue-list-toolbar-left').prepend(issueSelectAll);
3134
};
3235

33-
$issueCheckboxes.on('change', syncIssueSelectionState);
36+
for (const el of issueCheckboxes) {
37+
el.addEventListener('change', syncIssueSelectionState);
38+
}
3439

35-
$issueSelectAll.on('change', () => {
36-
$issueCheckboxes.prop('checked', $issueSelectAll.is(':checked'));
40+
issueSelectAll?.addEventListener('change', () => {
41+
for (const el of issueCheckboxes) {
42+
el.checked = issueSelectAll.checked;
43+
el.addEventListener('change', syncIssueSelectionState);
44+
}
3745
syncIssueSelectionState();
3846
});
3947

web_src/js/features/repo-legacy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ export function initRepository() {
534534
const gitignores = $('input[name="gitignores"]').val();
535535
const license = $('input[name="license"]').val();
536536
if (gitignores || license) {
537-
$('input[name="auto_init"]').prop('checked', true);
537+
document.querySelector('input[name="auto_init"]').checked = true;
538538
}
539539
});
540540
}

0 commit comments

Comments
 (0)