From d513899fc78ac512b96d11d86f4b83cbc13a0839 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 17 Aug 2023 09:11:30 +0200 Subject: [PATCH] Update the `StampEditor.isEmpty` method to handle File (PR 16828 follow-up) After the changes in PR 16828 the `StampEditor` can now be initialized with a File, in addition to a URL, hence it seems that the `isEmpty` method ought to take that property into account as well. Looking at this I also noticed that the assignment in the constructor may cause the `this.#bitmapUrl`/`this.#bitmapFile` fields be `undefined` which "breaks" the comparisons in the `isEmpty` method. We could obviously fix those specific cases, but it seemed overall safer (with future changes) to just update the `isEmpty` method to be less sensitive to exactly how these fields are initialized and reset. --- src/display/editor/stamp.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/display/editor/stamp.js b/src/display/editor/stamp.js index 00352c72f..caa374fb9 100644 --- a/src/display/editor/stamp.js +++ b/src/display/editor/stamp.js @@ -249,10 +249,11 @@ class StampEditor extends AnnotationEditor { /** @inheritdoc */ isEmpty() { - return ( - this.#bitmapPromise === null && - this.#bitmap === null && - this.#bitmapUrl === null + return !( + this.#bitmapPromise || + this.#bitmap || + this.#bitmapUrl || + this.#bitmapFile ); }