浏览代码

Fix TypeError: undefined is not an object

master
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
  * @param id {string} input id
164
  * @param id {string} input id
165
  */
165
  */
166
 function deferredFocus(id){
166
 function deferredFocus(id){
167
-    setTimeout(function (){
168
-        $(`#${id}`).focus();
169
-    }, 400);
167
+    setTimeout(() => $(`#${id}`).focus(), 400);
170
 }
168
 }
171
 /**
169
 /**
172
  * Chat related user interface.
170
  * Chat related user interface.
353
      * Scrolls chat to the bottom.
351
      * Scrolls chat to the bottom.
354
      */
352
      */
355
     scrollChatToBottom () {
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
 

正在加载...
取消
保存