Skip to content

Commit 7371f26

Browse files
committed
use utils
1 parent 8957d4f commit 7371f26

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

web_src/js/features/comp/TextExpander.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {matchEmoji, matchMention, matchIssue} from '../../utils/match.ts';
22
import {emojiString} from '../emoji.ts';
33
import {svg} from '../../svg.ts';
44
import {parseIssueHref} from '../../utils.ts';
5+
import {createElementFromAttrs, createElementFromHTML} from '../../utils/dom.ts';
56

67
type Issue = {id: number; title: string; state: 'open' | 'closed'; pull_request?: {draft: boolean; merged: boolean}};
78
function getIssueIcon(issue: Issue) {
@@ -92,14 +93,14 @@ export function initTextExpander(expander) {
9293
const ul = document.createElement('ul');
9394
ul.classList.add('suggestions');
9495
for (const issue of matches) {
95-
const li = document.createElement('li');
96+
const li = createElementFromAttrs('li', {
97+
role: 'option',
98+
'data-value': `${key}${issue.id}`,
99+
});
96100
li.classList.add('tw-flex', 'tw-gap-2');
97-
li.setAttribute('role', 'option');
98-
li.setAttribute('data-value', `${key}${issue.id}`);
99101

100-
const icon = document.createElement('div');
101-
icon.innerHTML = svg(getIssueIcon(issue), 16, ['text', getIssueColor(issue)].join(' ')).trim();
102-
li.append(icon.firstChild);
102+
const icon = svg(getIssueIcon(issue), 16, ['text', getIssueColor(issue)].join(' '));
103+
li.append(createElementFromHTML(icon));
103104

104105
const id = document.createElement('span');
105106
id.classList.add('id');

0 commit comments

Comments
 (0)