My aggregated monorepo of OCaml code, automaintained
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Force full page load when x-ocaml universe changes during SPA nav

x-ocaml.js initializes the worker and universe config once at script
load time. When SPA-navigating between pages with different universes
(e.g. demo1 using ./universe vs demo_widgets using /_opam), the old
worker stays alive with the wrong libraries.

Detect universe mismatch in navigateTo() by comparing the
x-ocaml-universe meta tags. If they differ, fall back to
window.location.href for a full page load.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+10
+10
odoc-jons-plugins/src/odoc_jons_plugins_js.ml
··· 181 181 var html = await response.text(); 182 182 var doc = parser.parseFromString(html, 'text/html'); 183 183 184 + // If the target page has a different x-ocaml universe, the worker 185 + // must be restarted. x-ocaml initializes once at script load, so 186 + // we fall back to a full page load to get a fresh environment. 187 + var curUniverse = (document.querySelector('meta[name="x-ocaml-universe"]') || {}).content || ''; 188 + var newUniverse = (doc.querySelector('meta[name="x-ocaml-universe"]') || {}).content || ''; 189 + if (curUniverse !== newUniverse) { 190 + window.location.href = ROOT_URL + url; 191 + return; 192 + } 193 + 184 194 // Swap content — use DOM node adoption instead of innerHTML so that 185 195 // custom elements (e.g. <x-ocaml>) get properly connected and their 186 196 // connectedCallback fires.