From 3baddadada637d631eab31490dc2754e67a3de10 Mon Sep 17 00:00:00 2001 From: Jennie Robinson Faber Date: Sun, 17 May 2026 19:11:27 +0100 Subject: [PATCH] Only attach license footer to ProseMirror's parent --- theme/license-footer.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/theme/license-footer.js b/theme/license-footer.js index b54c66d..752a0a0 100644 --- a/theme/license-footer.js +++ b/theme/license-footer.js @@ -8,25 +8,22 @@ return location.pathname.indexOf("/doc/") === 0; } - function findTarget() { - var pm = document.querySelector(".ProseMirror"); - if (pm && pm.parentElement) return pm.parentElement; - return ( - document.querySelector("article") || - document.querySelector("[role=main]") || - document.querySelector("main") - ); + function removeAll() { + document.querySelectorAll(".cc-license-footer").forEach(function (el) { + el.remove(); + }); } function render() { - var existing = document.querySelector(".cc-license-footer"); if (!isDoc()) { - if (existing) existing.remove(); + removeAll(); return; } - if (existing) return; - var target = findTarget(); - if (!target) return; + var pm = document.querySelector(".ProseMirror"); + if (!pm || !pm.parentElement) return; + var target = pm.parentElement; + if (target.querySelector(":scope > .cc-license-footer")) return; + removeAll(); var footer = document.createElement("footer"); footer.className = "cc-license-footer"; var p = document.createElement("p");