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.
This commit is contained in:
Ricardo
2026-01-28 17:24:00 +01:00
parent 924a21b9f8
commit 24f790c4cb

View File

@@ -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);
}
}