diff --git a/.gitignore b/.gitignore index f1138e7..0d2b1fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea/ node_modules .npm target diff --git a/src/paho-mqtt.js b/src/paho-mqtt.js index 9ca3d37..fd14176 100644 --- a/src/paho-mqtt.js +++ b/src/paho-mqtt.js @@ -1809,7 +1809,7 @@ function onMessageArrived(message) { "onConnected":{ get: function() { return client.onConnected; }, set: function(newOnConnected) { - if (typeof newOnConnected === "function") + if (newOnConnected === null || typeof newOnConnected === "function") client.onConnected = newOnConnected; else throw new Error(format(ERROR.INVALID_TYPE, [typeof newOnConnected, "onConnected"])); @@ -1830,7 +1830,7 @@ function onMessageArrived(message) { "onConnectionLost":{ get: function() { return client.onConnectionLost; }, set: function(newOnConnectionLost) { - if (typeof newOnConnectionLost === "function") + if (newOnConnectionLost === null || typeof newOnConnectionLost === "function") client.onConnectionLost = newOnConnectionLost; else throw new Error(format(ERROR.INVALID_TYPE, [typeof newOnConnectionLost, "onConnectionLost"])); @@ -1839,7 +1839,7 @@ function onMessageArrived(message) { "onMessageDelivered":{ get: function() { return client.onMessageDelivered; }, set: function(newOnMessageDelivered) { - if (typeof newOnMessageDelivered === "function") + if (newOnMessageDelivered === null || typeof newOnMessageDelivered === "function") client.onMessageDelivered = newOnMessageDelivered; else throw new Error(format(ERROR.INVALID_TYPE, [typeof newOnMessageDelivered, "onMessageDelivered"])); @@ -1848,7 +1848,7 @@ function onMessageArrived(message) { "onMessageArrived":{ get: function() { return client.onMessageArrived; }, set: function(newOnMessageArrived) { - if (typeof newOnMessageArrived === "function") + if (newOnMessageArrived === null || typeof newOnMessageArrived === "function") client.onMessageArrived = newOnMessageArrived; else throw new Error(format(ERROR.INVALID_TYPE, [typeof newOnMessageArrived, "onMessageArrived"])); @@ -1857,7 +1857,7 @@ function onMessageArrived(message) { "trace":{ get: function() { return client.traceFunction; }, set: function(trace) { - if(typeof trace === "function"){ + if (trace === null || typeof trace === "function"){ client.traceFunction = trace; }else{ throw new Error(format(ERROR.INVALID_TYPE, [typeof trace, "onTrace"]));