Fix TypeError: undefined is not an object

This commit is contained in:
Lyubo Marinov 2017-02-27 22:33:27 -06:00
parent 72c267fbf3
commit e1056126e6
1 changed files with 12 additions and 7 deletions

View File

@ -164,9 +164,7 @@ function resizeChatConversation() {
* @param id {string} input id * @param id {string} input id
*/ */
function deferredFocus(id){ function deferredFocus(id){
setTimeout(function (){ setTimeout(() => $(`#${id}`).focus(), 400);
$(`#${id}`).focus();
}, 400);
} }
/** /**
* Chat related user interface. * Chat related user interface.
@ -353,10 +351,17 @@ var Chat = {
* Scrolls chat to the bottom. * Scrolls chat to the bottom.
*/ */
scrollChatToBottom () { scrollChatToBottom () {
setTimeout(function () { setTimeout(
$('#chatconversation').scrollTop( () => {
$('#chatconversation')[0].scrollHeight); const chatconversation = $('#chatconversation');
}, 5);
// 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);
} }
}; };