Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CaiJimmy/hugo-theme-stack.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Cai <github@jimmycai.com>2022-02-12 16:23:38 +0300
committerGitHub <noreply@github.com>2022-02-12 16:23:38 +0300
commit0fbbc12949c8d59ea5ddcfb463d2c48140bfb490 (patch)
treea6445210a9ce1676dbb4309017462c4a73a006f5
parent4b0dbb4630c8a050c7b4e4cad51ab4a6efb29685 (diff)
fix: check if paragraph exists before accessing it's textContent
closes https://github.com/CaiJimmy/hugo-theme-stack/issues/490
-rw-r--r--assets/ts/gallery.ts2
1 files changed, 2 insertions, 0 deletions
diff --git a/assets/ts/gallery.ts b/assets/ts/gallery.ts
index ec7c02d..218658d 100644
--- a/assets/ts/gallery.ts
+++ b/assets/ts/gallery.ts
@@ -67,6 +67,8 @@ class StackGallery {
/// This is done to allow inline images within paragraphs
const paragraph = img.closest('p');
+ if (!paragraph || !container.contains(paragraph)) continue;
+
if (paragraph.textContent.trim() == '') {
/// Once we insert figcaption, this check no longer works
/// So we add a class to paragraph to mark it