Skip to content

Commit 185fee6

Browse files
committed
Use Map.prototype.getOrInsertComputed() in the web/struct_tree_layer_builder.js file
1 parent 0d4e587 commit 185fee6

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

web/struct_tree_layer_builder.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
/** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */
1717

18-
import { FeatureTest, shadow } from "pdfjs-lib";
18+
import { FeatureTest, makeMap, shadow } from "pdfjs-lib";
1919
import { removeNullCharacters } from "./ui_utils.js";
2020

2121
const PDF_ROLE_TO_HTML_ROLE = {
@@ -251,12 +251,9 @@ class StructTreeLayerBuilder {
251251
const label = removeNullCharacters(alt);
252252
for (const child of structElement.children) {
253253
if (child.type === "annotation") {
254-
let attrs = this.#elementAttributes.get(child.id);
255-
if (!attrs) {
256-
attrs = new Map();
257-
this.#elementAttributes.set(child.id, attrs);
258-
}
259-
attrs.set("aria-label", label);
254+
this.#elementAttributes
255+
.getOrInsertComputed(child.id, makeMap)
256+
.set("aria-label", label);
260257
added = true;
261258
}
262259
}

0 commit comments

Comments
 (0)