pantsdown 2.3.0 → 2.3.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantsdown",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Markdown to 'GitHub HTML' parser",
5
5
  "license": "MIT",
6
6
  "author": "wallpants",
package/src/javascript.ts CHANGED
@@ -308,7 +308,7 @@ function mermaidScript(config: PantsdownConfig["renderer"]["mermaid"]): string {
308
308
  // prefer the canvas svg: if a consumer re-injects html that was
309
309
  // serialized after a previous setup, the diagram svg sits inside
310
310
  // the old wrapper and stale button icons are svgs too
311
- const svg = el.querySelector(".mermaid-canvas svg") ?? el.querySelector("svg");
311
+ const svg = el.querySelector(".mermaid-canvas svg") ?? el.querySelector(":scope > svg");
312
312
  if (!svg) return;
313
313
 
314
314
  // serialized html loses event listeners, so stale wrappers and
@@ -342,14 +342,16 @@ function mermaidScript(config: PantsdownConfig["renderer"]["mermaid"]): string {
342
342
  }
343
343
 
344
344
  // mermaid renders asynchronously (the page loads mermaid.js separately),
345
- // so wait for the svg to replace the diagram source
345
+ // so wait for the svg to replace the diagram source. Only a direct-child
346
+ // svg counts: mermaid.run() renders in place via a nested temp div
347
+ // whose skeleton svg must not be grabbed mid-render
346
348
  function whenRendered(el, cb) {
347
- if (el.querySelector("svg")) {
349
+ if (el.querySelector(":scope > svg")) {
348
350
  cb();
349
351
  return;
350
352
  }
351
353
  const observer = new MutationObserver(() => {
352
- if (el.querySelector("svg")) {
354
+ if (el.querySelector(":scope > svg")) {
353
355
  observer.disconnect();
354
356
  cb();
355
357
  }