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
This commit is contained in:
2026-03-14 13:52:34 -04:00
parent 6ca0b3c5a8
commit 2f7ed70304
2 changed files with 95 additions and 31 deletions
@@ -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`
<div
class=${classMap({
@@ -1339,15 +1336,6 @@ export class QueuePanel
})}
data-index=${index}
draggable="true"
@click=${(e: MouseEvent) =>
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}
>
<span class="track-position">
${index + 1}
@@ -1362,8 +1350,6 @@ export class QueuePanel
</div>
<button
class="remove-button"
@click=${(e: Event) =>
this.handleRemoveTrack(e, index)}
title="Remove from queue"
>
<wa-icon name="xmark"></wa-icon>