mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
[api-minor] Let PDFPageProxy.getStructTree
return null
, rather than an empty structTree, for documents without any accessibility data (PR 13171 follow-up)
This is first of all consistent with existing API-methods, where we return `null` when the data in question doesn't exist. Secondly, it should also be (slightly) more efficient since there's less dummy-data that we need to transfer between threads. Finally, this prevents us from adding an empty/unnecessary span to *every* single page even in documents without any structure tree data.
This commit is contained in:
parent
ff4dae05b0
commit
5adee0cdd1
4 changed files with 72 additions and 1 deletions
|
@ -328,6 +328,10 @@ class StructTreePage {
|
|||
}
|
||||
nodeToSerializable(child, root);
|
||||
}
|
||||
|
||||
if (root.children.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return root;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1522,7 +1522,8 @@ class PDFPageProxy {
|
|||
|
||||
/**
|
||||
* @returns {Promise<StructTreeNode>} A promise that is resolved with a
|
||||
* {@link StructTreeNode} object that represents the page's structure tree.
|
||||
* {@link StructTreeNode} object that represents the page's structure tree,
|
||||
* or `null` when no structure tree is present for the current page.
|
||||
*/
|
||||
getStructTree() {
|
||||
return (this._structTreePromise ||= this._transport.getStructTree(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue