broaden anchor detection (not just anchor_N but anchor_anything)

master
Tomáš Mládek 2021-01-12 00:53:47 +01:00
parent 8b0e1c0fa8
commit 4c42baf268
1 changed files with 8 additions and 12 deletions

View File

@ -294,18 +294,14 @@ export default defineComponent({
}); });
function processAnchors(document: XMLDocument): SVGRectElement[] { function processAnchors(document: XMLDocument): SVGRectElement[] {
let result = []; const result: SVGRectElement[] = [];
let i = 1; Array.from(document.getElementsByTagName("rect"))
while (true) { .filter((el) => el.id.startsWith("anchor"))
let anchor = document.getElementById(`anchor_${i}`) as SVGRectElement | null; .forEach((anchor) => {
if (anchor === null) { console.debug(`[SVG/ANCHORS] Found anchor #${anchor.id}.`);
break; anchor.classList.add("internal");
} result.push(anchor);
console.debug(`[SVG/ANCHORS] Found anchor #${anchor.id}.`); });
anchor.classList.add("internal");
result.push(anchor);
i++;
}
return result; return result;
} }