Created
March 8, 2010 20:01
-
-
Save ciaranj/325521 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/node.js b/src/node.js | |
index afc70bf..8417460 100644 | |
--- a/src/node.js | |
+++ b/src/node.js | |
@@ -138,11 +138,10 @@ process.mixin = function() { | |
if (target === d.value) { | |
continue; | |
} | |
- | |
if (deep && d.value && typeof d.value === "object") { | |
target[k] = process.mixin(deep, | |
// Never move original objects, clone them | |
- source[k] || (d.value.length != null ? [] : {}) | |
+ target[k] || (d.value.length != null ? [] : {}) | |
, d.value); | |
} | |
else { | |
diff --git a/test/simple/test-process-mixin.js b/test/simple/test-process-mixin.js | |
index ca7bf95..87bbc75 100644 | |
--- a/test/simple/test-process-mixin.js | |
+++ b/test/simple/test-process-mixin.js | |
@@ -43,4 +43,13 @@ process.mixin(true, target, { | |
}); | |
assert.notStrictEqual(['bar'], target.foo); | |
-assert.deepEqual(['bar'], target.foo); | |
\ No newline at end of file | |
+assert.deepEqual(['bar'], target.foo); | |
+ | |
+// Test that nested literals are handled properly | |
+var sys= require('sys'); | |
+var source= {a: 'x', b: {c:"d"}}; | |
+var target= {b: {d:"e"}}; | |
+var result= process.mixin(true, target, source); | |
+assert.equal(result.a, 'x') | |
+assert.equal(result.b.c, 'd') | |
+assert.equal(result.b.d, 'e') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment