From 249c19b7df60373cc5ef6d067f8de59d8788c1cf Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Thu, 2 Apr 2020 13:24:45 +0000 Subject: [PATCH] condense: Skip over invalid content. We were defending against `content` being undefined, which is impossible, instead of checking the length of the jQuery object. --- static/js/condense.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/static/js/condense.js b/static/js/condense.js index 4b2437850f..d75014590c 100644 --- a/static/js/condense.js +++ b/static/js/condense.js @@ -178,8 +178,15 @@ exports.condense_and_collapse = function (elems) { for (const elem of elems) { const content = $(elem).find(".message_content"); + + if (content.length !== 1) { + // We could have a "/me did this" message or something + // else without a `message_content` div. + continue; + } + const message = current_msg_list.get(rows.id($(elem))); - if (content !== undefined && message !== undefined) { + if (message !== undefined) { const message_height = get_message_height(elem, message.id); const long_message = message_height > height_cutoff; if (long_message) {