incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From deedu...@apache.org
Subject git commit: Allow prototype overrides of constructor objects for merges.
Date Fri, 16 Mar 2012 18:37:08 GMT
Updated Branches:
  refs/heads/master 16f5c42bc -> 7e623fa95


Allow prototype overrides of constructor objects for merges.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/7e623fa9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/7e623fa9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/7e623fa9

Branch: refs/heads/master
Commit: 7e623fa9564866aa60cdf8ae375a3d11abf97490
Parents: 16f5c42
Author: Drew Walters <deedubbu@gmail.com>
Authored: Fri Mar 16 13:35:41 2012 -0500
Committer: Drew Walters <deedubbu@gmail.com>
Committed: Fri Mar 16 13:35:41 2012 -0500

----------------------------------------------------------------------
 lib/builder.js |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/7e623fa9/lib/builder.js
----------------------------------------------------------------------
diff --git a/lib/builder.js b/lib/builder.js
index 2578180..0ff2f73 100644
--- a/lib/builder.js
+++ b/lib/builder.js
@@ -57,10 +57,16 @@ function include(parent, objects, clobber, merge) {
 function recursiveMerge(target, src) {
     for (var prop in src) {
         if (src.hasOwnProperty(prop)) {
-            target[prop] = typeof src[prop] === 'object' ?
-                    recursiveMerge(target[prop], src[prop]) : src[prop];
+            if (typeof target.prototype !== 'undefined' && target.prototype.constructor
=== target) {
+                // If the target object is a constructor override off prototype.
+                target.prototype[prop] = src[prop];
+            } else {
+                target[prop] = typeof src[prop] === 'object' ? recursiveMerge(
+                        target[prop], src[prop]) : src[prop];
+            }
         }
     }
+    return target;
 }
 
 module.exports = {


Mime
View raw message