mnfst 0.5.58 → 0.5.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -226,6 +226,13 @@ function initializeCodePlugin() {
226
226
  }
227
227
 
228
228
  setupCodeGroup() {
229
+ // Idempotency: if a tab header is already present (from prerender output
230
+ // or a previous connection), skip rebuilding it. Otherwise the DOM ends
231
+ // up with a doubled tab row when the static page rehydrates.
232
+ if (this.querySelector(':scope > header[aria-label="Code examples"]')) {
233
+ return;
234
+ }
235
+
229
236
  // Find all x-code elements within this group
230
237
  const codeElements = this.querySelectorAll('x-code');
231
238
 
@@ -359,10 +366,19 @@ function initializeCodePlugin() {
359
366
  }
360
367
 
361
368
  connectedCallback() {
362
- this.setupElement();
363
- // Remove tabindex to prevent focusing the container itself
364
- // Focus should go to interactive elements like copy button
365
- this.highlightCode();
369
+ // Idempotency: if the element already has a fully-rendered structure
370
+ // (a <pre><code> child from prerender output), skip the rebuild.
371
+ // Reading innerHTML and re-setting it as textContent (extractContent
372
+ // line ~524) treats the prerendered hljs <span> markup as code
373
+ // source, producing nested highlight-of-highlight output.
374
+ const alreadyRendered =
375
+ this.querySelector(':scope > pre > code') &&
376
+ (this.hasAttribute('data-pre-rendered') ||
377
+ this.querySelector(':scope > pre > code.hljs, :scope > pre > code[data-highlighted="yes"]'));
378
+ if (!alreadyRendered) {
379
+ this.setupElement();
380
+ this.highlightCode();
381
+ }
366
382
  }
367
383
 
368
384
  attributeChangedCallback(name, oldValue, newValue) {