[Annotation] Replace use of id by data-element-id to have the correct id

This commit is contained in:
Calixte Denizet 2022-10-19 23:01:36 +02:00
parent ba3a0e104a
commit 6db9cefaaf
4 changed files with 28 additions and 1 deletions

View File

@ -551,7 +551,8 @@ class AnnotationElement {
// Fallback to a regular DOM lookup, to ensure that the standalone // Fallback to a regular DOM lookup, to ensure that the standalone
// viewer components won't break. // viewer components won't break.
for (const domElement of document.getElementsByName(name)) { for (const domElement of document.getElementsByName(name)) {
const { id, exportValue } = domElement; const { exportValue } = domElement;
const id = domElement.getAttribute("data-element-id");
if (id === skipId) { if (id === skipId) {
continue; continue;
} }

View File

@ -95,6 +95,31 @@ describe("Checkbox annotation", () => {
); );
}); });
}); });
describe("issue15597.pdf", () => {
let pages;
beforeAll(async () => {
pages = await loadAndWait("issue15597.pdf", "[data-annotation-id='7R']");
});
afterAll(async () => {
await closePages(pages);
});
it("must check the checkbox", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
const selector = "[data-annotation-id='7R']";
await page.click(selector);
await page.waitForFunction(
`document.querySelector("${selector} > :first-child").checked`
);
expect(true).withContext(`In ${browserName}`).toEqual(true);
})
);
});
});
}); });
describe("Text widget", () => { describe("Text widget", () => {

View File

@ -547,3 +547,4 @@
!bug1782564.pdf !bug1782564.pdf
!issue15340.pdf !issue15340.pdf
!bug1795263.pdf !bug1795263.pdf
!issue15597.pdf

BIN
test/pdfs/issue15597.pdf Executable file

Binary file not shown.