From 4d9cf4695d8bce28c978555e409f710c68b2c24c Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sun, 29 Dec 2019 15:30:18 +0000 Subject: [PATCH] Fix broken display of MathML when there are no images in the document Former-commit-id: 8e5397d0aa6655e24a5c1a049ab7f80e47284985 [formerly 1674afb4ad3e84dc391345f1a94d880e25974bcd] Former-commit-id: 2c487839063561e0f6f6bc6db5032bf4e1b00746 --- CHANGELOG.md | 1 + www/index.html | 3 ++- www/js/lib/images.js | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 556fc5df..fbd9012c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Release 0.9.9.96 (beta) * FIX: Broken display of Kiwix download library +* FIX: Broken display of MathML when there are no images in the document * FIX: Search bar always remains on-screen if selected (in non-mobile contexts) * FIX: All images above the fold are now loaded (async timing of image scanning was premature) * FIX: Math typeset by KaTeX is rendered better when there are mbox statements (fbox is used instead) diff --git a/www/index.html b/www/index.html index 20e880f7..7dd5e802 100644 --- a/www/index.html +++ b/www/index.html @@ -108,12 +108,13 @@

Changes in 0.9 (beta)

Full changelog...

diff --git a/www/js/lib/images.js b/www/js/lib/images.js index 0588ac43..98a8a59a 100644 --- a/www/js/lib/images.js +++ b/www/js/lib/images.js @@ -198,6 +198,8 @@ define(['uiUtil'], function (uiUtil) { function prepareImagesServiceWorker (forPrinting) { var doc = iframe.contentDocument.documentElement; documentImages = doc.querySelectorAll('img'); + // Schedule loadMathJax here in case next line aborts this function + setTimeout(loadMathJax, 1000); if (!forPrinting && !documentImages.length) return; var imageHtml; for (var i = 0, l = documentImages.length; i < l; i++) { @@ -229,12 +231,13 @@ define(['uiUtil'], function (uiUtil) { setTimeout(lazyLoad, 100); } } - setTimeout(loadMathJax, 1000); } function prepareImagesJQuery (forPrinting) { var doc = iframe.contentDocument.documentElement; documentImages = doc.querySelectorAll('img[data-kiwixurl]'); + // In case there are no images in the doc, we need to schedule the loadMathJax function here + setTimeout(loadMathJax, 1000); if (!forPrinting && !documentImages.length) return; if (forPrinting) { extractImages(documentImages, params.preloadingAllImages ? params.preloadAllImages : params.printImagesLoaded); @@ -251,9 +254,6 @@ define(['uiUtil'], function (uiUtil) { // User wishes to extract images manually prepareManualExtraction(); } - //loadMathJax(); - setTimeout(loadMathJax, 1000); - } /**