Context
This follow-up task was identified during the review of PR #58.
Source PR: #58
PR Title: fix: cross-handler SPA navigation, navigation edge cases, and Tier 1 file uploads
Suggested by: @claude[bot]
Priority: Low (cosmetic)
Task Description
In handleNavigationResponse, the non-LiveTemplate page fallback path (when the fetched response has no [data-lvt-id] wrapper) calls setupEventDelegation() and linkInterceptor.setup(wrapperElement) after replacing the wrapper content with the response's <body> children.
The handlers then run on content that has NO LiveTemplate elements — every delegated event will match nothing and no-op. Not harmful, but misleading: a reader of the code might assume setup is meaningful here, and a future change might accidentally rely on it.
Proposed Fix
Skip the setup calls entirely in the non-LVT fallback path, OR add a clear comment explaining why they're still called (if there's a reason I'm missing).
// Non-LiveTemplate page — tear down and use body content fallback
this.linkInterceptor.teardownForWrapper(oldId);
this.eventDelegator.teardownForWrapper(oldId);
this.disconnect();
const body = doc.querySelector("body");
if (body) {
this.wrapperElement.replaceChildren(...);
}
// No setupEventDelegation/linkInterceptor.setup — the content has no
// LiveTemplate elements, so delegated handlers would just no-op.
Original Comment
In the same-handler path, teardownForWrapper is not called before re-running setup. The comment says the setup methods are idempotent, but if that contract ever breaks, stale listeners accumulate silently. A defensive teardown call before the same-handler setup would be cheap insurance.
...
After the body-content fallback, setupEventDelegation and linkInterceptor.setup are called on content with no LiveTemplate elements. The handlers will no-op on every event. Not harmful, but slightly misleading.
This issue was created from PR #58 review comments.
Context
This follow-up task was identified during the review of PR #58.
Source PR: #58
PR Title: fix: cross-handler SPA navigation, navigation edge cases, and Tier 1 file uploads
Suggested by: @claude[bot]
Priority: Low (cosmetic)
Task Description
In
handleNavigationResponse, the non-LiveTemplate page fallback path (when the fetched response has no[data-lvt-id]wrapper) callssetupEventDelegation()andlinkInterceptor.setup(wrapperElement)after replacing the wrapper content with the response's<body>children.The handlers then run on content that has NO LiveTemplate elements — every delegated event will match nothing and no-op. Not harmful, but misleading: a reader of the code might assume setup is meaningful here, and a future change might accidentally rely on it.
Proposed Fix
Skip the setup calls entirely in the non-LVT fallback path, OR add a clear comment explaining why they're still called (if there's a reason I'm missing).
Original Comment
This issue was created from PR #58 review comments.