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[] {
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;
}