diff --git a/Source/Ejecta/EJUtils/EJBindingWebSocket.m b/Source/Ejecta/EJUtils/EJBindingWebSocket.m index 393efecf..b9fb5aa4 100644 --- a/Source/Ejecta/EJUtils/EJBindingWebSocket.m +++ b/Source/Ejecta/EJUtils/EJBindingWebSocket.m @@ -100,7 +100,7 @@ - (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reas JSContextRef ctx = scriptView.jsGlobalContext; [self triggerEvent:@"close" properties:(JSEventProperty[]){ {"code", JSValueMakeNumber(ctx, code)}, - {"reason", NSStringToJSValue(ctx, reason)}, + {"reason", reason ? NSStringToJSValue(ctx, reason) : scriptView->jsUndefined }, {"wasClean", JSValueMakeBoolean(ctx, wasClean)}, {NULL, NULL}, }];