mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-17 14:24:07 +00:00
Clean up refreshViewedFilesSummary (#36868)
1. Use `textContent` instead of `innerHTML` to fix https://github.com/go-gitea/gitea/security/code-scanning/170. 2. Clean up surrounding code to remove unnecessary `if` checks on elements that are guaranteed to exist. --------- Co-authored-by: Claude (Opus 4.6) <noreply@anthropic.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
@@ -9,13 +9,13 @@ const viewedCheckboxSelector = '.viewed-file-form'; // Selector under which all
|
||||
const expandFilesBtnSelector = '#expand-files-btn';
|
||||
const collapseFilesBtnSelector = '#collapse-files-btn';
|
||||
|
||||
// Refreshes the summary of viewed files if present
|
||||
// Refreshes the summary of viewed files
|
||||
// The data used will be window.config.pageData.prReview.numberOf{Viewed}Files
|
||||
function refreshViewedFilesSummary() {
|
||||
const viewedFilesProgress = document.querySelector('#viewed-files-summary');
|
||||
viewedFilesProgress?.setAttribute('value', prReview.numberOfViewedFiles);
|
||||
const summaryLabel = document.querySelector('#viewed-files-summary-label')!;
|
||||
if (summaryLabel) summaryLabel.innerHTML = summaryLabel.getAttribute('data-text-changed-template')!
|
||||
const viewedFilesProgress = document.querySelector('#viewed-files-summary')!;
|
||||
viewedFilesProgress.setAttribute('value', prReview.numberOfViewedFiles);
|
||||
const summaryLabel = document.querySelector<HTMLElement>('#viewed-files-summary-label')!;
|
||||
summaryLabel.textContent = summaryLabel.getAttribute('data-text-changed-template')!
|
||||
.replace('%[1]d', prReview.numberOfViewedFiles)
|
||||
.replace('%[2]d', prReview.numberOfFiles);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user