瀏覽代碼

Fix TypeError: undefined is not an object

j8
Lyubo Marinov 8 年之前
父節點
當前提交
e1056126e6
共有 1 個檔案被更改,包括 12 行新增7 行删除
  1. 12
    7
      modules/UI/side_pannels/chat/Chat.js

+ 12
- 7
modules/UI/side_pannels/chat/Chat.js 查看文件

@@ -164,9 +164,7 @@ function resizeChatConversation() {
164 164
  * @param id {string} input id
165 165
  */
166 166
 function deferredFocus(id){
167
-    setTimeout(function (){
168
-        $(`#${id}`).focus();
169
-    }, 400);
167
+    setTimeout(() => $(`#${id}`).focus(), 400);
170 168
 }
171 169
 /**
172 170
  * Chat related user interface.
@@ -353,10 +351,17 @@ var Chat = {
353 351
      * Scrolls chat to the bottom.
354 352
      */
355 353
     scrollChatToBottom () {
356
-        setTimeout(function () {
357
-            $('#chatconversation').scrollTop(
358
-                $('#chatconversation')[0].scrollHeight);
359
-        }, 5);
354
+        setTimeout(
355
+            () => {
356
+                const chatconversation = $('#chatconversation');
357
+
358
+                // XXX Prevent TypeError: undefined is not an object when the
359
+                // Web browser does not support WebRTC (yet).
360
+                chatconversation.length > 0
361
+                    && chatconversation.scrollTop(
362
+                            chatconversation[0].scrollHeight);
363
+            },
364
+            5);
360 365
     }
361 366
 };
362 367
 

Loading…
取消
儲存