Shorten the AnnotationElement.prototype._getElementsByName method a tiny bit

This commit is contained in:
Jonas Jenwald 2026-07-28 19:04:17 +02:00
parent 8d1afad39b
commit 3736000aee

View File

@ -803,27 +803,24 @@ class AnnotationElement {
const fields = []; const fields = [];
if (this._fieldObjects) { if (this._fieldObjects) {
const fieldObj = this._fieldObjects[name]; const fieldObj = this._fieldObjects[name] || [];
if (fieldObj) {
for (const { page, id, exportValues } of fieldObj) {
if (page === -1) {
continue;
}
if (id === skipId) {
continue;
}
const exportValue =
typeof exportValues === "string" ? exportValues : null;
const domElement = document.querySelector( for (const { page, id, exportValues } of fieldObj) {
`[data-element-id="${id}"]` if (page === -1) {
); continue;
if (domElement && !GetElementsByNameSet.has(domElement)) {
warn(`_getElementsByName - element not allowed: ${id}`);
continue;
}
fields.push({ id, exportValue, domElement });
} }
if (id === skipId) {
continue;
}
const exportValue =
typeof exportValues === "string" ? exportValues : null;
const domElement = document.querySelector(`[data-element-id="${id}"]`);
if (domElement && !GetElementsByNameSet.has(domElement)) {
warn(`_getElementsByName - element not allowed: ${id}`);
continue;
}
fields.push({ id, exportValue, domElement });
} }
return fields; return fields;
} }