From 111898ee0e3236fb864558f652fbe503442411b4 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sat, 3 Oct 2026 22:30:03 -0400 Subject: [PATCH] fix(paginator): bail from expand() when the iframe document is torn down A queued resize tick can run against a not-yet-parsed or unloaded iframe; documentElement is null then and expand() threw inside the ResizeObserver callback. Observed live in the Android app (twice in row during boot and page turns). Follows the 50f56ee guard family. --- package.json | 2 +- paginator.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 7ab75dd..f3a14b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "foliate-js", - "version": "0.5.0", + "version": "0.5.1", "description": "Render e-books in the browser", "repository": { "type": "git", diff --git a/paginator.js b/paginator.js index 4149be8..fa9dbef 100644 --- a/paginator.js +++ b/paginator.js @@ -381,6 +381,10 @@ class View { } } expand() { + // A queued resize tick can run against a torn-down or + // not-yet-parsed iframe; bail instead of throwing (the caller + // re-renders on the next real observation). + if (!this.document?.documentElement) return const { documentElement } = this.document if (this.#column) { const side = this.#vertical ? 'height' : 'width'