-
Notifications
You must be signed in to change notification settings - Fork 476
Description
I ran into a strange issue, where a link click causes the <noscript> tag and its child <style> on my page to be parsed and evaluated.
Adding an id and data-turbo-permanent="true" is a workaround for this, but only works for successful visits.
On the error page, the content of <noscript> remains invisible, but it contains a <style> tag, which is evaluated and causes the content of the page to be set to display: none;.
The errors on my website are not static; they are rendered within the default layout and attempt to keep navigation/breadcrumbs as intact as possible.
However, when Turbo renders 4xx/5xx errors, it seems to re-evaluate everything, even elements that are marked as permanent.
My browser also warns me that there may be no more than one importmap, which supports my "re-evaluate everything" assumption.
My workaround is this ugly hack:
document.addEventListener("turbo:before-render", (event) => {
const noscriptTag = event.detail.newBody.querySelector("noscript");
if (noscriptTag && noscriptTag.querySelector("style")) noscriptTag.innerText = noscriptTag.innerHTML;
});
Also, the warning about a second importmap being loaded remains, which is also not nice.
Surely this can't be the intended behavior? What is causing the duplicate importmap?