Prevent double-loading of afterDOMReady scripts (#2213)

Co-authored-by: Adam <adam@canny.io>
This commit is contained in:
Adam LaycockandAdam authored and GitHub committed 2025-11-27 14:51:56 -08:00
1 parent c99c8070f2
commit 87f7f4804e
3 files changed
+7 -6

No files matched your search

+1 -1
View File
@@ -294,7 +294,7 @@ export function renderPage(
</body>
{pageResources.js
.filter((resource) => resource.loadTime === "afterDOMReady")
.map((res) => JSResourceToScriptElement(res))}
.map((res) => JSResourceToScriptElement(res, true))}
</html>
)
+2 -2
View File
@@ -115,9 +115,9 @@ async function _navigate(url: URL, isBack: boolean = false) {
}
// now, patch head, re-executing scripts
const elementsToRemove = document.head.querySelectorAll(":not([spa-preserve])")
const elementsToRemove = document.head.querySelectorAll(":not([data-persist])")
elementsToRemove.forEach((el) => el.remove())
const elementsToAdd = html.head.querySelectorAll(":not([spa-preserve])")
const elementsToAdd = html.head.querySelectorAll(":not([data-persist])")
elementsToAdd.forEach((el) => document.head.appendChild(el))
// delay setting the url until now