cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [1/2] js commit: CB-7868 Use utils.defineGetterSetter instead of Object.defineProperty which may or may not be defined
Date Mon, 27 Oct 2014 23:51:33 GMT
Repository: cordova-js
Updated Branches:
  refs/heads/master 9da67a3ae -> 91157c2e1


CB-7868 Use utils.defineGetterSetter instead of Object.defineProperty which may or may not
be defined


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

Branch: refs/heads/master
Commit: bd5a35fac8ce04deda9317831aea3a4489b9fc33
Parents: 14fae3a
Author: purplecabbage <purplecabbage@gmail.com>
Authored: Mon Oct 27 15:56:01 2014 -0700
Committer: purplecabbage <purplecabbage@gmail.com>
Committed: Mon Oct 27 15:56:01 2014 -0700

----------------------------------------------------------------------
 src/common/init.js   | 17 ++++++++---------
 src/common/init_b.js | 16 +++++++---------
 2 files changed, 15 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/bd5a35fa/src/common/init.js
----------------------------------------------------------------------
diff --git a/src/common/init.js b/src/common/init.js
index 758544e..46cca2e 100644
--- a/src/common/init.js
+++ b/src/common/init.js
@@ -24,6 +24,7 @@ var cordova = require('cordova');
 var modulemapper = require('cordova/modulemapper');
 var platform = require('cordova/platform');
 var pluginloader = require('cordova/pluginloader');
+var utils = require('cordova/utils');
 
 var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
 
@@ -55,21 +56,19 @@ function replaceNavigator(origNavigator) {
         for (var key in origNavigator) {
             if (typeof origNavigator[key] == 'function') {
                 newNavigator[key] = origNavigator[key].bind(origNavigator);
-            } else {
+            } 
+            else {
                 (function(k) {
-                        Object.defineProperty(newNavigator, k, {
-                            get: function() {
-                                return origNavigator[k];
-                            },
-                            configurable: true,
-                            enumerable: true
-                        });
-                    })(key);
+                    utils.defineGetterSetter(newNavigator,key,function() {
+                        return origNavigator[k];
+                    });
+                })(key);
             }
         }
     }
     return newNavigator;
 }
+
 if (window.navigator) {
     window.navigator = replaceNavigator(window.navigator);
 }

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/bd5a35fa/src/common/init_b.js
----------------------------------------------------------------------
diff --git a/src/common/init_b.js b/src/common/init_b.js
index f00409b..207cc3c 100644
--- a/src/common/init_b.js
+++ b/src/common/init_b.js
@@ -22,6 +22,7 @@
 var channel = require('cordova/channel');
 var cordova = require('cordova');
 var platform = require('cordova/platform');
+var utils = require('cordova/utils');
 
 var platformInitChannelsArray = [channel.onDOMContentLoaded, channel.onNativeReady];
 
@@ -56,16 +57,13 @@ function replaceNavigator(origNavigator) {
         for (var key in origNavigator) {
             if (typeof origNavigator[key] == 'function') {
                 newNavigator[key] = origNavigator[key].bind(origNavigator);
-            } else {
+            } 
+            else {
                 (function(k) {
-                        Object.defineProperty(newNavigator, k, {
-                            get: function() {
-                                return origNavigator[k];
-                            },
-                            configurable: true,
-                            enumerable: true
-                        });
-                    })(key);
+                    utils.defineGetterSetter(newNavigator,key,function() {
+                        return origNavigator[k];
+                    });
+                })(key);
             }
         }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message