diff options
author | Arnout Kazemier <info@3rd-Eden.com> | 2011-03-04 10:14:58 +0100 |
---|---|---|
committer | Arnout Kazemier <info@3rd-Eden.com> | 2011-03-04 10:14:58 +0100 |
commit | d9fea247acb905a993a6d17fa1eb0bab2322ebd8 (patch) | |
tree | dbbfb33a44f2c0bba6255cfe0488f6ba4ed38530 | |
parent | d7ab7546570d83ad7fcd65c84b3dab45d003b6e7 (diff) | |
download | web-socket-js-d9fea247acb905a993a6d17fa1eb0bab2322ebd8.tar.gz |
The handler should not "invalid events" for valid events. Just because we
didn't attach a handler for it doesn't indicate that it's not a valid event.
-rw-r--r-- | web_socket.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/web_socket.js b/web_socket.js index 9951c71..abd5093 100644 --- a/web_socket.js +++ b/web_socket.js @@ -158,14 +158,14 @@ if ("readyState" in event) { this.readyState = event.readyState; } - + try { - if (event.type == "open" && this.onopen) { - this.onopen(); - } else if (event.type == "close" && this.onclose) { - this.onclose(); - } else if (event.type == "error" && this.onerror) { - this.onerror(event); + if (event.type == "open") { + this.onopen && this.onopen(); + } else if (event.type == "close") { + this.onclose && this.onclose(); + } else if (event.type == "error") { + this.onerror && this.onerror(event); } else if (event.type == "message") { if (this.onmessage) { var data = decodeURIComponent(event.message); |