broaden anchor detection (not just anchor_N but anchor_anything)

This commit is contained in:
Tomáš Mládek 2021-01-12 00:53:47 +01:00
parent 8b0e1c0fa8
commit 4c42baf268

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;
}