diff --git a/src/node.js b/src/node.js index a1054206c8..221a5a2657 100644 --- a/src/node.js +++ b/src/node.js @@ -126,7 +126,7 @@ process.mixin = function() { if ( (source = arguments[i]) != null ) { // Extend the base object Object.getOwnPropertyNames(source).forEach(function(k){ - var d = Object.getOwnPropertyDescriptor(source, k); + var d = Object.getOwnPropertyDescriptor(source, k) || {value: source[k]}; if (d.get) { target.__defineGetter__(k, d.get); if (d.set) { diff --git a/test/simple/test-process-mixin.js b/test/simple/test-process-mixin.js index 18d21f53ef..ca7bf9545b 100644 --- a/test/simple/test-process-mixin.js +++ b/test/simple/test-process-mixin.js @@ -28,10 +28,19 @@ var source = { get foo(){ return this._foo; }, set foo(value){ this._foo = "did set to "+value; } }; -var target = {}; +target = {}; process.mixin(target, source); target._foo = 'b'; assert.equal(source.foo, 'a'); assert.equal('b', target.foo, 'target.foo != "b" -- value/result was copied instead of getter function'); source.foo = 'c'; assert.equal('did set to c', source.foo, 'source.foo != "c" -- value was set instead of calling setter function'); + +// Test that nested arrays are handled properly +target = {}; +process.mixin(true, target, { + foo: ['bar'], +}); + +assert.notStrictEqual(['bar'], target.foo); +assert.deepEqual(['bar'], target.foo); \ No newline at end of file