My aggregated monorepo of OCaml code, automaintained
0
fork

Configure Feed

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

Add odoc-spa-loaded event for extension SPA support

The SPA shell now dispatches a 'odoc-spa-loaded' custom event on
document after all external scripts from the fetched page have
loaded and inline scripts have executed. Extensions listen for
this event instead of polling for CDN library availability.

This replaces the unreliable polling approach — the MutationObserver
fires before CDN scripts load, and no further mutations occur to
trigger re-rendering. The custom event fires at exactly the right
moment: after content is swapped AND all scripts are ready.

Updated mermaid, dot, and msc extensions to use the new event.

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

+3 -1
+3 -1
src/odoc_jons_plugins_js.ml
··· 257 257 } 258 258 }); 259 259 260 - // After external scripts load, execute inline scripts (deduplicated) 260 + // After external scripts load, execute inline scripts (deduplicated), 261 + // then fire a custom event so extensions know all resources are ready. 261 262 Promise.all(newScriptLoadPromises).then(function() { 262 263 inlineScripts.forEach(function(el) { 263 264 var id = el.getAttribute('data-spa-inline'); ··· 265 266 var s = el.cloneNode(true); 266 267 document.head.appendChild(s); 267 268 }); 269 + document.dispatchEvent(new CustomEvent('odoc-spa-loaded')); 268 270 }); 269 271 270 272 // Update state