You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2012/11/07 21:19:04 UTC

[2/3] js commit: [all] Never use platform's navigator.connection. Always clobber

[all] Never use platform's navigator.connection. Always clobber

-Also adds the ability for common.js to clobber / merge things.
-This fixes Android's navigator.connection problem. (CB-1807)


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/557dab7e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/557dab7e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/557dab7e

Branch: refs/heads/master
Commit: 557dab7e8e562eb7b5d5086f10f64b267758c5fc
Parents: 41ef8a7
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Nov 7 15:13:47 2012 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Nov 7 15:17:56 2012 -0500

----------------------------------------------------------------------
 lib/common/common.js     |   12 +++++++++---
 lib/scripts/bootstrap.js |   20 ++++++++++++++++----
 2 files changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/557dab7e/lib/common/common.js
----------------------------------------------------------------------
diff --git a/lib/common/common.js b/lib/common/common.js
index c622f7a..cbcac1e 100644
--- a/lib/common/common.js
+++ b/lib/common/common.js
@@ -56,9 +56,6 @@ module.exports = {
                 compass:{
                     path: 'cordova/plugin/compass'
                 },
-                connection: {
-                    path: 'cordova/plugin/network'
-                },
                 contacts: {
                     path: 'cordova/plugin/contacts'
                 },
@@ -226,5 +223,14 @@ module.exports = {
         resolveLocalFileSystemURI:{
             path: 'cordova/plugin/resolveLocalFileSystemURI'
         }
+    },
+    clobbers: {
+        navigator: {
+            children: {
+                connection: {
+                    path: 'cordova/plugin/network'
+                }
+            },
+        }
     }
 };

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/557dab7e/lib/scripts/bootstrap.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap.js b/lib/scripts/bootstrap.js
index 58ca32d..e7f1a0e 100644
--- a/lib/scripts/bootstrap.js
+++ b/lib/scripts/bootstrap.js
@@ -22,8 +22,8 @@
 (function (context) {
     // Replace navigator before any modules are required(), to ensure it happens as soon as possible.
     // We replace it so that properties that can't be clobbered can instead be overridden.
-    if (typeof context.navigator != 'undefined') {
-        var CordovaNavigator = function () {};
+    if (context.navigator) {
+        function CordovaNavigator() {}
         CordovaNavigator.prototype = context.navigator;
         context.navigator = new CordovaNavigator();
     }
@@ -42,13 +42,25 @@
                     // Drop the common globals into the window object, but be nice and don't overwrite anything.
                     builder.build(base.objects).intoButDoNotClobber(context);
 
+                    if (base.merges) {
+                        builder.build(base.merges).intoAndMerge(context);
+                    }
+
+                    if (base.clobbers) {
+                        builder.build(base.clobbers).intoAndClobber(context);
+                    }
+
                     // Drop the platform-specific globals into the window object
                     // and clobber any existing object.
-                    builder.build(platform.objects).intoAndClobber(context);
+                    if (platform.object) {
+                        builder.build(platform.objects).intoAndClobber(context);
+                    }
 
                     // Merge the platform-specific overrides/enhancements into
                     // the window object.
-                    builder.build(platform.merges).intoAndMerge(context);
+                    if (platform.merges) {
+                        builder.build(platform.merges).intoAndMerge(context);
+                    }
 
                     // Call the platform-specific initialization
                     platform.initialize();