| 17 | ] as const; |
| 18 | |
| 19 | function maybeAddIconLegacy(filename: HTMLAnchorElement): void { |
| 20 | const list = $optional('ul[aria-label="File Tree"]'); |
| 21 | if (!list && pageDetect.isCommit()) { |
| 22 | // Silence error, single-file commits don't have the file list |
| 23 | return; |
| 24 | } |
| 25 | |
| 26 | const fileInList = $optional(`[href="${filename.hash}"]`, list); |
| 27 | if (!fileInList) { |
| 28 | features.unload(import.meta.url); |
| 29 | throw new Error('Could not find file in sidebar, is the sidebar loaded?'); |
| 30 | } |
| 31 | |
| 32 | const icon = $optional(['.octicon-diff-removed', '.octicon-diff-added'], fileInList); |
| 33 | if (icon) { |
| 34 | // `span` needed for native vertical alignment |
| 35 | filename.parentElement!.append( |
| 36 | <span className="ml-1 tmp-ml-1">{icon.cloneNode(true)}</span>, |
| 37 | ); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | function maybeAddIcon(fileHeader: HTMLDivElement): void { |
| 42 | const fileLink = $('a', fileHeader); |