Use querySelector
over alternative DOM methods (#31280)
As per https://github.com/go-gitea/gitea/pull/30115#discussion_r1626060164, prefer `querySelector` by enabling [`unicorn/prefer-query-selector`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-query-selector.md) and autofixing all except 10 issues. According to [this](https://old.reddit.com/r/learnjavascript/comments/i0f5o8/performance_of_getelementbyid_vs_queryselector/), querySelector may be faster as well, so it's a win-win. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
parent
a2304cb163
commit
507fbf4c3c
47 changed files with 165 additions and 168 deletions
|
@ -1,13 +1,13 @@
|
|||
import {hideElem, showElem, toggleElem} from '../utils/dom.js';
|
||||
|
||||
const service = document.getElementById('service_type');
|
||||
const user = document.getElementById('auth_username');
|
||||
const pass = document.getElementById('auth_password');
|
||||
const token = document.getElementById('auth_token');
|
||||
const mirror = document.getElementById('mirror');
|
||||
const lfs = document.getElementById('lfs');
|
||||
const lfsSettings = document.getElementById('lfs_settings');
|
||||
const lfsEndpoint = document.getElementById('lfs_endpoint');
|
||||
const service = document.querySelector('#service_type');
|
||||
const user = document.querySelector('#auth_username');
|
||||
const pass = document.querySelector('#auth_password');
|
||||
const token = document.querySelector('#auth_token');
|
||||
const mirror = document.querySelector('#mirror');
|
||||
const lfs = document.querySelector('#lfs');
|
||||
const lfsSettings = document.querySelector('#lfs_settings');
|
||||
const lfsEndpoint = document.querySelector('#lfs_endpoint');
|
||||
const items = document.querySelectorAll('#migrate_items input[type=checkbox]');
|
||||
|
||||
export function initRepoMigration() {
|
||||
|
@ -18,16 +18,16 @@ export function initRepoMigration() {
|
|||
pass?.addEventListener('input', () => {checkItems(false)});
|
||||
token?.addEventListener('input', () => {checkItems(true)});
|
||||
mirror?.addEventListener('change', () => {checkItems(true)});
|
||||
document.getElementById('lfs_settings_show')?.addEventListener('click', (e) => {
|
||||
document.querySelector('#lfs_settings_show')?.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
showElem(lfsEndpoint);
|
||||
});
|
||||
lfs?.addEventListener('change', setLFSSettingsVisibility);
|
||||
|
||||
const cloneAddr = document.getElementById('clone_addr');
|
||||
const cloneAddr = document.querySelector('#clone_addr');
|
||||
cloneAddr?.addEventListener('change', () => {
|
||||
const repoName = document.getElementById('repo_name');
|
||||
const repoName = document.querySelector('#repo_name');
|
||||
if (cloneAddr.value && !repoName?.value) { // Only modify if repo_name input is blank
|
||||
repoName.value = cloneAddr.value.match(/^(.*\/)?((.+?)(\.git)?)$/)[3];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue