From 4c42baf268db5f71cded570ec2ed62d44f8b424b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Tue, 12 Jan 2021 00:53:47 +0100 Subject: [PATCH] broaden anchor detection (not just anchor_N but anchor_anything) --- app/src/components/SVGContent.vue | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/app/src/components/SVGContent.vue b/app/src/components/SVGContent.vue index 0d3a7e0..5e52197 100644 --- a/app/src/components/SVGContent.vue +++ b/app/src/components/SVGContent.vue @@ -294,18 +294,14 @@ export default defineComponent({ }); function processAnchors(document: XMLDocument): SVGRectElement[] { - let result = []; - let i = 1; - while (true) { - let anchor = document.getElementById(`anchor_${i}`) as SVGRectElement | null; - if (anchor === null) { - break; - } - console.debug(`[SVG/ANCHORS] Found anchor #${anchor.id}.`); - anchor.classList.add("internal"); - result.push(anchor); - i++; - } + const result: SVGRectElement[] = []; + Array.from(document.getElementsByTagName("rect")) + .filter((el) => el.id.startsWith("anchor")) + .forEach((anchor) => { + console.debug(`[SVG/ANCHORS] Found anchor #${anchor.id}.`); + anchor.classList.add("internal"); + result.push(anchor); + }); return result; }