1// Declarative Shadow DOM (<template shadowrootmode="open">) is promoted to a 2// real shadow root only by the browser's HTML parser. Turbo Drive swaps <body> 3// via DOM operations instead of re-parsing HTML, so after a Turbo navigation 4// those templates stay inert and any content inside them stays hidden. 5// 6// This module walks unattached templates on every Turbo load and mounts them 7// manually so custom elements like <goboony-footer> render consistently. 8function rehydrate(root = document) { 9 root.querySelectorAll("template[shadowrootmode]").forEach((template) => { 10 const host = template.parentNode 11 if (!host || host.shadowRoot) return 12 13 const mode = template.getAttribute("shadowrootmode") 14 try { 15 const shadow = host.attachShadow({ mode }) 16 shadow.appendChild(template.content.cloneNode(true)) 17 template.remove() 18 } catch (e) { 19 // Host already has a shadow root, or it doesn't support attachShadow â 20 // leave the template in place and move on. 21 } 22 }) 23} 24 25document.addEventListener("turbo:load", () => rehydrate()) 26document.addEventListener("turbo:frame-load", (event) => rehydrate(event.target))
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.