From 6e06fe2885f2250d446d613215dbadf63d08a766 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 08:31:24 +0300 Subject: [PATCH] shorten_expanded: fix for posts without attachments --- plugins/shorten_expanded/init.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js index 181e426a4..873749c03 100644 --- a/plugins/shorten_expanded/init.js +++ b/plugins/shorten_expanded/init.js @@ -25,20 +25,23 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { if (row) { const content = row.querySelector(".content-inner"); - const attachments = row.querySelector(".attachments-inline"); - if (content && attachments && - row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) { + //console.log('shorten', row.offsetHeight, 'vs', _shorten_expanded_threshold * window.innerHeight); + + if (content && row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) { + + const attachments = row.querySelector(".attachments-inline"); // optional content.innerHTML = `
${content.innerHTML} - ${attachments.innerHTML} + ${attachments ? attachments.innerHTML : ''}
`; - attachments.innerHTML = ""; + if (attachments) + attachments.innerHTML = ""; dojo.parser.parse(content); }