Prevent double-loading of afterDOMReady scripts (#2213)

Co-authored-by: Adam <adam@canny.io>
This commit is contained in:
Adam Laycock 2025-11-27 15:51:56 -07:00 committed by GitHub
commit 87f7f4804e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 6 deletions

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