diff --git a/src/node.js b/src/node.js index 2a52c251c8..1e091d0289 100644 --- a/src/node.js +++ b/src/node.js @@ -109,7 +109,7 @@ process.mixin = function() { } // Handle case when target is a string or something (possible in deep copy) - if ( typeof target !== "object" && !process.isFunction(target) ) + if ( typeof target !== "object" && !(typeof target === 'function') ) target = {}; // mixin process itself if only one argument is passed @@ -130,7 +130,7 @@ process.mixin = function() { continue; // Recurse if we're merging object values - if ( deep && copy && typeof copy === "object" && !copy.nodeType ) + if ( deep && copy && typeof copy === "object" ) target[ name ] = process.mixin( deep, // Never move original objects, clone them src || ( copy.length != null ? [ ] : { } ) diff --git a/test/mjsunit/test-process-mixin.js b/test/mjsunit/test-process-mixin.js new file mode 100644 index 0000000000..840079a35d --- /dev/null +++ b/test/mjsunit/test-process-mixin.js @@ -0,0 +1,16 @@ +process.mixin(require("./common")); + +var target = function() {}; +process.mixin(target, { + foo: 'bar' +}); + +assert.equal('bar', target.foo); + +// This test verifies there are no DOM-related aspects to process.mixin which +// originally had been in there due to its jQuery origin. +var fakeDomElement = {deep: {nodeType: 4}}; +target = {}; +process.mixin(true, target, fakeDomElement); + +assert.notStrictEqual(target.deep, fakeDomElement.deep); \ No newline at end of file