Skip to content

Commit

Permalink
A couple of small TextHighlighter/TextLayerBuilder tweaks (PR 139…
Browse files Browse the repository at this point in the history
…08 follow-up)

 - Use `Node.TEXT_NODE` rather than a magical constant, in `TextHighlighter._convertMatches`, to improve readability. According to MDN, this has been supported since "forever": https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#browser_compatibility

 - Remove the `pageIdx`-property, on `TextLayerBuilder`-instances, since the re-factoring in PR 13908 meant that it's now unused.

 - Remove the `matches`-property, on `TextLayerBuilder`-instances, since the re-factoring in PR 13908 meant that it's now unused.
  • Loading branch information
Snuffleupagus authored and rousek committed Aug 10, 2022
1 parent 4e53ff7 commit 96b3412
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion web/text_highlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class TextHighlighter {

function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
let div = textDivs[divIdx];
if (div.nodeType === 3) {
if (div.nodeType === Node.TEXT_NODE) {
const span = document.createElement("span");
div.parentNode.insertBefore(span, div);
span.appendChild(div);
Expand Down
4 changes: 1 addition & 3 deletions web/text_layer_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ class TextLayerBuilder {
this.textContentItemsStr = [];
this.textContentStream = null;
this.renderingDone = false;
this.pageIdx = pageIndex;
this.pageNumber = this.pageIdx + 1;
this.matches = [];
this.pageNumber = pageIndex + 1;
this.viewport = viewport;
this.textDivs = [];
this.textLayerRenderTask = null;
Expand Down

0 comments on commit 96b3412

Please sign in to comment.