From e1056126e6c7f3f5d1b1322d2f6d0e24fcead2d7 Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Mon, 27 Feb 2017 22:33:27 -0600 Subject: [PATCH] Fix TypeError: undefined is not an object --- modules/UI/side_pannels/chat/Chat.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/UI/side_pannels/chat/Chat.js b/modules/UI/side_pannels/chat/Chat.js index 5c1f0746f..6b4545e3e 100644 --- a/modules/UI/side_pannels/chat/Chat.js +++ b/modules/UI/side_pannels/chat/Chat.js @@ -164,9 +164,7 @@ function resizeChatConversation() { * @param id {string} input id */ function deferredFocus(id){ - setTimeout(function (){ - $(`#${id}`).focus(); - }, 400); + setTimeout(() => $(`#${id}`).focus(), 400); } /** * Chat related user interface. @@ -353,10 +351,17 @@ var Chat = { * Scrolls chat to the bottom. */ scrollChatToBottom () { - setTimeout(function () { - $('#chatconversation').scrollTop( - $('#chatconversation')[0].scrollHeight); - }, 5); + setTimeout( + () => { + const chatconversation = $('#chatconversation'); + + // XXX Prevent TypeError: undefined is not an object when the + // Web browser does not support WebRTC (yet). + chatconversation.length > 0 + && chatconversation.scrollTop( + chatconversation[0].scrollHeight); + }, + 5); } };