about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-05-24 20:12:40 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-05-24 20:12:40 +0300
commit9942c9e5c5863fd66c945ec96125779cd382d611 (patch)
tree66a390aac766c366115aa0783b50a80a54897468 /src
parent101393993492bbba837c93d47cc33c3e4b906c21 (diff)
downloadthe-epube-9942c9e5c5863fd66c945ec96125779cd382d611.tar.gz
the-epube-9942c9e5c5863fd66c945ec96125779cd382d611.tar.xz
fix another object may be undefined TS check
Diffstat (limited to 'src')
-rw-r--r--src/app.js2
-rw-r--r--src/reader.js9
2 files changed, 7 insertions, 4 deletions
diff --git a/src/app.js b/src/app.js
index 5c1ba4f..2bed544 100644
--- a/src/app.js
+++ b/src/app.js
@@ -204,7 +204,7 @@ class AppClass extends AppCommon {
 
 						img.attr("src", null);
 					})
-					.attr("src", e.attr('data-cover-link'));
+					.attr("src", e.attr('data-cover-link') ?? "");
 			}
 		});
 	}
diff --git a/src/reader.js b/src/reader.js
index 32f907c..3340203 100644
--- a/src/reader.js
+++ b/src/reader.js
@@ -1587,10 +1587,13 @@ class ReaderClass extends AppCommon {
 	}
 
 	/**
-	 * @param {string} a
-	 * @param {string} b
+	 * @param {?string} a
+	 * @param {?string} b
 	 */
 	calculateCfiDelta(a, b) {
+		if (!a || !b)
+			return -1;
+
 		// @ts-ignore
 		const acfi = new ePub.CFI(a);
 		// @ts-ignore
@@ -1643,7 +1646,7 @@ class ReaderClass extends AppCommon {
 			}
 
 			try {
-				const delta = this.calculateCfiDelta(cfi, moved_to);
+				const delta = this.calculateCfiDelta(cfi, moved_to ?? null);
 
 				console.log(`opened cfi ${moved_to} expected ${cfi}; delta: ${delta}`);