Skip to content

Commit ef92920

Browse files
Merge pull request #20103 from calixteman/avoid_undefined_id
Don't add an undefined id to the span for marked content
2 parents 9f645fb + 86d58b6 commit ef92920

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/display/text_layer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class TextLayer {
290290
const parent = this.#container;
291291
this.#container = document.createElement("span");
292292
this.#container.classList.add("markedContent");
293-
if (item.id !== null) {
293+
if (item.id) {
294294
this.#container.setAttribute("id", `${item.id}`);
295295
}
296296
parent.append(this.#container);

test/integration/accessibility_spec.mjs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,4 +281,25 @@ describe("accessibility", () => {
281281
);
282282
});
283283
});
284+
285+
describe("No undefined id", () => {
286+
let pages;
287+
288+
beforeEach(async () => {
289+
pages = await loadAndWait("issue20102.pdf", ".textLayer");
290+
});
291+
292+
afterEach(async () => {
293+
await closePages(pages);
294+
});
295+
296+
it("must check that span hasn't an 'undefined' id", async () => {
297+
await Promise.all(
298+
pages.map(async ([browserName, page]) => {
299+
const id = await page.$eval("span.markedContent", span => span.id);
300+
expect(id).withContext(`In ${browserName}`).toBe("");
301+
})
302+
);
303+
});
304+
});
284305
});

test/pdfs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,3 +732,4 @@
732732
!bug1974436.pdf
733733
!firefox_logo.pdf
734734
!issue20062.pdf
735+
!issue20102.pdf

test/pdfs/issue20102.pdf

13.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)