From d9fea247acb905a993a6d17fa1eb0bab2322ebd8 Mon Sep 17 00:00:00 2001 From: Arnout Kazemier Date: Fri, 4 Mar 2011 10:14:58 +0100 Subject: 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. --- web_socket.js | 14 +++++++------- 1 file 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); -- cgit v1.2.1