From 2f7ed7030425ed0ebb7a1a186917a79a7b26b850 Mon Sep 17 00:00:00 2001 From: Caleb Allen Date: Sat, 14 Mar 2026 13:52:34 -0400 Subject: [PATCH] perf(14-03): eliminate per-item closure allocation in scroll render paths - Replace inline arrow closures in renderTrackRow with event delegation via data-index - Replace inline arrow closures in renderTrackItem with event delegation via data-index - Add delegated click/dblclick/contextmenu/dragstart handlers on virtualizer elements - Remove button click in queue panel also delegated via closest('.remove-button') - Zero new function objects created per renderItem call during scroll --- .../src/components/queue-panel/queue-panel.ts | 18 +-- .../src/components/track-list/track-list.ts | 108 +++++++++++++++--- 2 files changed, 95 insertions(+), 31 deletions(-) diff --git a/frontend/src/components/queue-panel/queue-panel.ts b/frontend/src/components/queue-panel/queue-panel.ts index e204ec4..5926c94 100644 --- a/frontend/src/components/queue-panel/queue-panel.ts +++ b/frontend/src/components/queue-panel/queue-panel.ts @@ -1264,11 +1264,6 @@ export class QueuePanel // Other handlers // ================================================================= - private handleRemoveTrack(e: Event, position: number) { - e.stopPropagation(); - this.queue.removeFromQueue(position); - } - private getDisplayTitle(track: { title: string; filePath: string; @@ -1328,6 +1323,8 @@ export class QueuePanel dropIdx === trackCount && index === trackCount - 1; + // No inline closures — all events delegated via data-index + // on the virtualizer element (see firstUpdated). return html`
- this.handleTrackClick(e, track, index)} - @dblclick=${() => - this.handleTrackDblClick(index)} - @contextmenu=${(e: MouseEvent) => - this.handleTrackContextMenu(e, index)} - @dragstart=${(e: DragEvent) => - this.onTrackDragStart(e, index)} - @dragend=${this.onTrackDragEnd} > ${index + 1} @@ -1362,8 +1350,6 @@ export class QueuePanel