From 30ef37381b067849c54c0933e49e8f5099fc86bb Mon Sep 17 00:00:00 2001 From: Bendik Aagaard Lynghaug Date: Wed, 21 Oct 2026 15:09:47 +0200 Subject: [PATCH] =?UTF-8?q?hero.js:=20midlertidige=20=3Fhero=3D=20brytere?= =?UTF-8?q?=20for=20=C3=A5=20finne=20hva=20som=20forstyrrer=20hydreringen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5.1 --- hero.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hero.js b/hero.js index 3393b6c..6b79b4e 100644 --- a/hero.js +++ b/hero.js @@ -308,6 +308,7 @@ const CSS = ` `; function ensureStyle() { + if (DEBUG.has('nostyle')) return; if (document.getElementById(STYLE_ID)) return; const style = document.createElement('style'); style.id = STYLE_ID; @@ -336,7 +337,7 @@ class WestraHero { this.hero = container.closest('.hero') || container.parentElement; // Where the module's custom properties go: an element the app // never hydrates, so writing to it cannot disturb hydration. - this.host = document.body; + this.host = DEBUG.has('nobody') ? document.createElement('div') : document.body; this.reduced = window.matchMedia('(prefers-reduced-motion: reduce)'); this.dark = window.matchMedia('(prefers-color-scheme: dark)'); @@ -357,7 +358,7 @@ class WestraHero { this.mark = mark; // Both inside the piece, and nothing outside it (see .westra-line). this.container = container; - container.append(this.canvas, this.name); + if (!DEBUG.has('nodom')) container.append(this.canvas, this.name); this.width = 0; this.height = 1; @@ -601,6 +602,13 @@ class WestraHero { } } +// Temporary, to find what disturbs hydration on the live site: +// ?hero=off mounts nothing, ?hero=nostyle skips the stylesheet, +// ?hero=nobody skips the custom properties on , ?hero=nodom +// adds nothing to the piece. Removed once known. +const DEBUG = new Set((new URLSearchParams(location.search).get('hero') || '').split(',')); + export function mount(container) { + if (DEBUG.has('off')) return { stop() {} }; return new WestraHero(container); }