diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js b/packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js
index 32ba905af..852f64058 100644
--- a/packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js
+++ b/packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js
@@ -722,6 +722,9 @@ RED.clipboard = (function() {
// representation or null
return null;
}
+ if (value.type === 'undefined') {
+ return undefined;
+ }
}
}
return value;
diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js b/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js
index e8306bd0f..6227fa683 100644
--- a/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js
+++ b/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js
@@ -52,7 +52,9 @@ RED.utils = (function() {
} else if (value === null) {
result = $('null');
} else if (typeof value === 'object') {
- if (value.hasOwnProperty('type') && value.type === 'Buffer' && value.hasOwnProperty('data')) {
+ if (value.hasOwnProperty('type') && value.type === 'undefined') {
+ result = $('undefined');
+ } else if (value.hasOwnProperty('type') && value.type === 'Buffer' && value.hasOwnProperty('data')) {
result = $('').text('buffer['+value.length+']');
} else if (value.hasOwnProperty('type') && value.type === 'array' && value.hasOwnProperty('data')) {
result = $('').text('array['+value.length+']');
@@ -348,6 +350,8 @@ RED.utils = (function() {
}
if (obj === null || obj === undefined) {
$(''+obj+'').appendTo(entryObj);
+ } else if (obj.__enc__ && obj.type === 'undefined') {
+ $('undefined').appendTo(entryObj);
} else if (obj.__enc__ && obj.type === 'number') {
e = $('').text(obj.data).appendTo(entryObj);
} else if (typeHint === "function" || (obj.__enc__ && obj.type === 'function')) {
diff --git a/packages/node_modules/@node-red/util/lib/util.js b/packages/node_modules/@node-red/util/lib/util.js
index f69ca890a..1141661de 100644
--- a/packages/node_modules/@node-red/util/lib/util.js
+++ b/packages/node_modules/@node-red/util/lib/util.js
@@ -771,6 +771,11 @@ function encodeObject(msg,opts) {
} else if (value.constructor.name === "Socket") {
value = "[internal]"
}
+ } else if (value === undefined) {
+ value = {
+ __enc__: true,
+ type: "undefined",
+ }
}
return value;
}," ");
diff --git a/test/unit/@node-red/util/lib/util_spec.js b/test/unit/@node-red/util/lib/util_spec.js
index aa46bc0e1..c4a64d53f 100644
--- a/test/unit/@node-red/util/lib/util_spec.js
+++ b/test/unit/@node-red/util/lib/util_spec.js
@@ -740,6 +740,19 @@ describe("@node-red/util/util", function() {
resultJson.name.should.eql('my error obj');
resultJson.message.should.eql('my error message');
});
+
+ it('object with undefined property', function() {
+ var msg = { msg:{a:1,b:undefined,c:3 } };
+ var result = util.encodeObject(msg);
+ result.format.should.eql("Object");
+ var resultJson = JSON.parse(result.msg);
+ resultJson.should.have.property("a",1);
+ resultJson.should.have.property("c",3);
+ resultJson.should.have.property("b");
+ resultJson.b.should.have.property("__enc__", true);
+ resultJson.b.should.have.property("type", "undefined");
+ });
+
it('constructor of IncomingMessage', function() {
function IncomingMessage(){};
var msg = { msg:new IncomingMessage() };
@@ -791,6 +804,16 @@ describe("@node-red/util/util", function() {
resultJson[0].should.eql('abc...');
resultJson[1].should.eql('123...');
});
+ it('array containing undefined', function() {
+ var msg = { msg:[1,undefined,3]};
+ var result = util.encodeObject(msg);
+ result.format.should.eql("array[3]");
+ var resultJson = JSON.parse(result.msg);
+ resultJson[0].should.eql(1);
+ resultJson[2].should.eql(3);
+ resultJson[1].__enc__.should.be.true();
+ resultJson[1].type.should.eql("undefined");
+ });
it('array of function', function() {
var msg = { msg:[function(){}] };
var result = util.encodeObject(msg);