Skip to content

Commit 34095dd

Browse files
committed
improve
1 parent a6f114b commit 34095dd

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

web_src/js/features/repo-diff.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,12 @@ import {validateTextareaNonEmpty} from './comp/ComboMarkdownEditor.ts';
66
import {initViewedCheckboxListenerFor, countAndUpdateViewedFiles, initExpandAndCollapseFilesButton} from './pull-view-file.ts';
77
import {initImageDiff} from './imagediff.ts';
88
import {showErrorToast} from '../modules/toast.ts';
9-
import {
10-
submitEventSubmitter,
11-
queryElemSiblings,
12-
hideElem,
13-
showElem,
14-
animateOnce,
15-
addDelegatedEventListener,
16-
createElementFromHTML, queryElems,
17-
} from '../utils/dom.ts';
9+
import {submitEventSubmitter, queryElemSiblings, hideElem, showElem, animateOnce, addDelegatedEventListener, createElementFromHTML, queryElems} from '../utils/dom.ts';
1810
import {POST, GET} from '../modules/fetch.ts';
1911
import {fomanticQuery} from '../modules/fomantic/base.ts';
2012
import {createTippy} from '../modules/tippy.ts';
2113
import {invertFileFolding} from './file-fold.ts';
14+
import {parseDom} from '../utils.ts';
2215

2316
const {i18n} = window.config;
2417

@@ -174,7 +167,7 @@ async function loadMoreFiles(btn: Element): Promise<boolean> {
174167
try {
175168
const response = await GET(url);
176169
const resp = await response.text();
177-
const respDoc = new DOMParser().parseFromString(resp, 'text/html');
170+
const respDoc = parseDom(resp, 'text/html');
178171
const respFileBoxes = respDoc.querySelector('#diff-file-boxes');
179172
// the response is a full HTML page, we need to extract the relevant contents:
180173
// * append the newly loaded file list items to the existing list
@@ -206,7 +199,7 @@ function initRepoDiffShowMore() {
206199
try {
207200
const response = await GET(url);
208201
const resp = await response.text();
209-
const respDoc = new DOMParser().parseFromString(resp, 'text/html');
202+
const respDoc = parseDom(resp, 'text/html');
210203
const respFileBody = respDoc.querySelector('#diff-file-boxes .diff-file-body .file-body');
211204
el.parentElement.replaceWith(...Array.from(respFileBody.children));
212205
// FIXME: calling onShowMoreFiles is not quite right here.

0 commit comments

Comments
 (0)