소스 검색

web-socket-js: Add function invocation fix.

Related to this issue:
https://github.com/gimite/web-socket-js/issues/#issue/50

This prevents the "Uncaught exception: TypeError:
'this.__handleEvents' is not a function" everytime the timer fires.

Yay, one of Javascript's worst behaviors; the way it sets "this".
Joel Martin 14 년 전
부모
커밋
b43c9838a5
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      include/web-socket-js/web_socket.js

+ 2 - 1
include/web-socket-js/web_socket.js

@@ -165,8 +165,9 @@
           if (this.__timer) clearInterval(this.__timer);
           if (window.opera) {
             // Workaround for weird behavior of Opera which sometimes drops events.
+            var that = this;
             this.__timer = setInterval(function () {
-              this.__handleEvents();
+              that.__handleEvents();
             }, 500);
           }
           if (this.onopen) this.onopen();