From 24f790c4cb0938de674189db384864a3ad4a34a0 Mon Sep 17 00:00:00 2001 From: Ricardo Date: Wed, 28 Jan 2026 17:24:00 +0100 Subject: [PATCH] fix: properly create webmentions section before appending type sections When no build-time webmentions exist, the first type to be processed was silently dropped because createWebmentionsSection() only creates the wrapper, not the type-specific section. After calling it, the code tried to find the selector which still didn't exist. Fixed by: create wrapper if needed, then always append the section to the wrapper and get the row/list from the newly created section. --- js/webmentions.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/js/webmentions.js b/js/webmentions.js index 92406a3..0cbb301 100644 --- a/js/webmentions.js +++ b/js/webmentions.js @@ -86,13 +86,14 @@ // Create section if it doesn't exist if (!row) { const section = createAvatarSection(type); - const webmentionsSection = document.getElementById('webmentions'); + let webmentionsSection = document.getElementById('webmentions'); + if (!webmentionsSection) { + createWebmentionsSection(); + webmentionsSection = document.getElementById('webmentions'); + } if (webmentionsSection) { webmentionsSection.appendChild(section); row = section.querySelector('.avatar-row'); - } else { - createWebmentionsSection(); - row = document.querySelector(selector); } } @@ -126,13 +127,14 @@ // Create section if it doesn't exist if (!list) { const section = createReplySection(); - const webmentionsSection = document.getElementById('webmentions'); + let webmentionsSection = document.getElementById('webmentions'); + if (!webmentionsSection) { + createWebmentionsSection(); + webmentionsSection = document.getElementById('webmentions'); + } if (webmentionsSection) { webmentionsSection.appendChild(section); list = section.querySelector('ul'); - } else { - createWebmentionsSection(); - list = document.querySelector(selector); } } @@ -220,13 +222,14 @@ if (!list) { const section = createMentionSection(); - const webmentionsSection = document.getElementById('webmentions'); + let webmentionsSection = document.getElementById('webmentions'); + if (!webmentionsSection) { + createWebmentionsSection(); + webmentionsSection = document.getElementById('webmentions'); + } if (webmentionsSection) { webmentionsSection.appendChild(section); list = section.querySelector('ul'); - } else { - createWebmentionsSection(); - list = document.querySelector(selector); } }