diff options
Diffstat (limited to 'source/features/linkify-urls-in-code.tsx')
-rw-r--r-- | source/features/linkify-urls-in-code.tsx | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/source/features/linkify-urls-in-code.tsx b/source/features/linkify-urls-in-code.tsx index c46ba764..60ffe510 100644 --- a/source/features/linkify-urls-in-code.tsx +++ b/source/features/linkify-urls-in-code.tsx @@ -23,17 +23,20 @@ const options = { } }; -export const editTextNodes = (fn, el) => { +export const editTextNodes = ( + fn: typeof linkifyIssues | typeof linkifyUrls, + el: HTMLElement +) => { for (const textNode of getTextNodes(el)) { - if (fn === linkifyUrls && textNode.textContent.length < 11) { // Shortest url: http://j.mp + if (fn === linkifyUrls && textNode.textContent!.length < 11) { // Shortest url: http://j.mp continue; } - const linkified = fn(textNode.textContent, options); + const linkified = fn(textNode.textContent!, options); if (linkified.children.length > 0) { // Children are <a> if (fn === linkifyIssues) { // Enable native issue title fetch - for (const link of linkified.children) { + for (const link of (linkified.children as HTMLCollectionOf<HTMLAnchorElement>)) { const issue = link.href.split('/').pop(); link.setAttribute('class', 'issue-link js-issue-link tooltipped tooltipped-ne'); link.setAttribute('data-error-text', 'Failed to load issue title'); @@ -48,7 +51,7 @@ export const editTextNodes = (fn, el) => { } }; -function init() { +function init(): false | void { const wrappers = select.all(` .blob-wrapper:not(.${linkifiedURLClass}), .comment-body:not(.${linkifiedURLClass}) |