Skip to content

Commit

Permalink
Merge pull request mozilla#18990 from Snuffleupagus/ensure-structTree…
Browse files Browse the repository at this point in the history
…-serializable

Ensure that serializing of StructTree-data cannot fail during loading
  • Loading branch information
Snuffleupagus authored Nov 2, 2024
2 parents aa4839e + b26dc19 commit e548510
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ class Page {
const structTree = await this.pdfManager.ensure(this, "_parseStructTree", [
structTreeRoot,
]);
return structTree.serializable;
return this.pdfManager.ensure(structTree, "serializable");
}

/**
Expand Down
10 changes: 8 additions & 2 deletions web/struct_tree_layer_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,14 @@ class StructTreeLayerBuilder {
}

async getAriaAttributes(annotationId) {
await this.render();
return this.#elementAttributes.get(annotationId);
try {
await this.render();
return this.#elementAttributes.get(annotationId);
} catch {
// If the structTree cannot be fetched, parsed, and/or rendered,
// ensure that e.g. the AnnotationLayer won't break completely.
}
return null;
}

hide() {
Expand Down

0 comments on commit e548510

Please sign in to comment.