Skip to content

Commit

Permalink
Enable no-jquery/no-parse-html-literal and fix violation (#31684)
Browse files Browse the repository at this point in the history
Tested it, path segment creation works just like before.
  • Loading branch information
silverwind authored Jul 27, 2024
1 parent a40192d commit aa36989
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ rules:
no-jquery/no-param: [2]
no-jquery/no-parent: [0]
no-jquery/no-parents: [2]
no-jquery/no-parse-html-literal: [0]
no-jquery/no-parse-html-literal: [2]
no-jquery/no-parse-html: [2]
no-jquery/no-parse-json: [2]
no-jquery/no-parse-xml: [2]
Expand Down
12 changes: 8 additions & 4 deletions web_src/js/features/repo-editor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import $ from 'jquery';
import {htmlEscape} from 'escape-goat';
import {createCodeEditor} from './codeeditor.ts';
import {hideElem, queryElems, showElem} from '../utils/dom.ts';
import {hideElem, queryElems, showElem, createElementFromHTML} from '../utils/dom.ts';
import {initMarkupContent} from '../markup/content.ts';
import {attachRefIssueContextPopup} from './contextpopup.ts';
import {POST} from '../modules/fetch.ts';
Expand Down Expand Up @@ -61,7 +61,7 @@ export function initRepoEditor() {
});
}

const filenameInput = document.querySelector('#file-name');
const filenameInput = document.querySelector<HTMLInputElement>('#file-name');
function joinTreePath() {
const parts = [];
for (const el of document.querySelectorAll('.breadcrumb span.section')) {
Expand All @@ -80,8 +80,12 @@ export function initRepoEditor() {
const value = parts[i];
if (i < parts.length - 1) {
if (value.length) {
$(`<span class="section"><a href="#">${htmlEscape(value)}</a></span>`).insertBefore($(filenameInput));
$('<div class="breadcrumb-divider">/</div>').insertBefore($(filenameInput));
filenameInput.before(createElementFromHTML(
`<span class="section"><a href="#">${htmlEscape(value)}</a></span>`,
));
filenameInput.before(createElementFromHTML(
`<div class="breadcrumb-divider">/</div>`,
));
}
} else {
filenameInput.value = value;
Expand Down

0 comments on commit aa36989

Please sign in to comment.