From c277e39b0bfce88c95c568e7ac5008e224229832 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 22 Feb 2021 12:42:59 +0100 Subject: [PATCH] Remove the `findResultsCount`-check from `PDFFindBar.updateResultsCount`, and unnecessary defaults from the constructor Given that `PDFFindBar` is written *specifically* for the default viewer, rather than general usage (as opposed to the `PDFFindController`), we should be able to simply assume that the `findResultsCount` DOM-element is always present. Even more so, when we're purposely not doing any similar checks for other DOM-elements in this code. Also, remove unnecessary `null` defaults for the various DOM-element options in the constructor, since the code simply assumes that all of the relevant DOM-elements are in fact available. --- web/pdf_find_bar.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/web/pdf_find_bar.js b/web/pdf_find_bar.js index 79969f372..b7ff4bf03 100644 --- a/web/pdf_find_bar.js +++ b/web/pdf_find_bar.js @@ -28,16 +28,16 @@ class PDFFindBar { constructor(options, eventBus, l10n = NullL10n) { this.opened = false; - this.bar = options.bar || null; - this.toggleButton = options.toggleButton || null; - this.findField = options.findField || null; - this.highlightAll = options.highlightAllCheckbox || null; - this.caseSensitive = options.caseSensitiveCheckbox || null; - this.entireWord = options.entireWordCheckbox || null; - this.findMsg = options.findMsg || null; - this.findResultsCount = options.findResultsCount || null; - this.findPreviousButton = options.findPreviousButton || null; - this.findNextButton = options.findNextButton || null; + this.bar = options.bar; + this.toggleButton = options.toggleButton; + this.findField = options.findField; + this.highlightAll = options.highlightAllCheckbox; + this.caseSensitive = options.caseSensitiveCheckbox; + this.entireWord = options.entireWordCheckbox; + this.findMsg = options.findMsg; + this.findResultsCount = options.findResultsCount; + this.findPreviousButton = options.findPreviousButton; + this.findNextButton = options.findNextButton; this.eventBus = eventBus; this.l10n = l10n; @@ -147,9 +147,6 @@ class PDFFindBar { } updateResultsCount({ current = 0, total = 0 } = {}) { - if (!this.findResultsCount) { - return; // No UI control is provided. - } const limit = MATCHES_COUNT_LIMIT; let matchesCountMsg = "";