Don't add an undefined id to the span for marked content

It fixes #20102.
This commit is contained in:
Calixte Denizet 2025-07-17 19:13:26 +02:00
parent 9f645fb9a6
commit 86d58b637f
4 changed files with 174 additions and 1 deletions

View File

@ -290,7 +290,7 @@ class TextLayer {
const parent = this.#container;
this.#container = document.createElement("span");
this.#container.classList.add("markedContent");
if (item.id !== null) {
if (item.id) {
this.#container.setAttribute("id", `${item.id}`);
}
parent.append(this.#container);

View File

@ -281,4 +281,25 @@ describe("accessibility", () => {
);
});
});
describe("No undefined id", () => {
let pages;
beforeEach(async () => {
pages = await loadAndWait("issue20102.pdf", ".textLayer");
});
afterEach(async () => {
await closePages(pages);
});
it("must check that span hasn't an 'undefined' id", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
const id = await page.$eval("span.markedContent", span => span.id);
expect(id).withContext(`In ${browserName}`).toBe("");
})
);
});
});
});

View File

@ -732,3 +732,4 @@
!bug1974436.pdf
!firefox_logo.pdf
!issue20062.pdf
!issue20102.pdf

151
test/pdfs/issue20102.pdf Executable file

File diff suppressed because one or more lines are too long