Merge branch 'optimize-completion-dom-updates'

This commit is contained in:
Oliver Blanthorn 2026-04-16 12:35:00 +02:00
commit 0f0aaef006
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
2 changed files with 5 additions and 8 deletions

View file

@ -304,14 +304,8 @@ export abstract class CompletionSourceFuse extends CompletionSource {
/** Call to replace the current display */
updateDisplay() {
const fragment = document.createDocumentFragment()
for (const option of this.options) {
if (option.state !== "hidden") {
fragment.appendChild(option.html)
}
}
this.optionContainer.innerHTML = ""
this.optionContainer.appendChild(fragment)
const visibleOptions = this.options.filter(o => o.state !== "hidden").map(o => o.html)
this.optionContainer.replaceChildren(...visibleOptions)
this.next(0)
}

3
src/tridactyl.d.ts vendored
View file

@ -59,6 +59,9 @@ interface HTMLElement {
// Let's be future proof:
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
focus(options?: any): void
// https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren
replaceChildren(...nodes: Node[]): void
}
/* eslint-disable @typescript-eslint/ban-types */