From 23f05c2cc4e16d83f852596b7c07f996b9ce39ff Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 6 Feb 2024 13:47:11 -0500 Subject: [PATCH] Fix collectFacsChildren() to get all element@facs recursively --- src/utils/ConvertMei.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/utils/ConvertMei.ts b/src/utils/ConvertMei.ts index 0b93b2a7f..dc69d1c46 100644 --- a/src/utils/ConvertMei.ts +++ b/src/utils/ConvertMei.ts @@ -381,7 +381,6 @@ export function convertToVerovio(sbBasedMei: string): string { if (!nextSb) { const lastElement = childrenArray.at(-1); const facsChildren = collectFacsChildren(lastElement, []); - const zones = Array.from(surface.querySelectorAll('zone')); for (const child of facsChildren) { const zone = zones.find(z => z.getAttribute('xml:id') == child.getAttribute('facs').slice(1)); if (zone) { @@ -577,11 +576,8 @@ export function removeColumnLabel(mei: string): string { } function collectFacsChildren(element: Element, array: Element[]): Element[] { + if (element.hasAttribute('facs')) array.push(element); for (const child of element.children) { - if (child.hasAttribute('facs')) { - array.push(child); - } - // Recursively call the function for child's children collectFacsChildren(child, array); }