You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sg...@apache.org on 2014/09/26 23:20:09 UTC
[10/13] git commit: CB-6481 Context opts should copy not reference
CB-6481 Context opts should copy not reference
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/b74d87d8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/b74d87d8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/b74d87d8
Branch: refs/heads/master
Commit: b74d87d8ef1f2f5a7c967e50cdb3d177119833bc
Parents: 1b5ce69
Author: Carlos Santana <cs...@gmail.com>
Authored: Fri Aug 8 09:30:06 2014 -0400
Committer: daserge <da...@yandex.ru>
Committed: Thu Sep 25 19:06:15 2014 +0400
----------------------------------------------------------------------
cordova-lib/src/hooks/Context.js | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b74d87d8/cordova-lib/src/hooks/Context.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/hooks/Context.js b/cordova-lib/src/hooks/Context.js
index b299597..889e283 100644
--- a/cordova-lib/src/hooks/Context.js
+++ b/cordova-lib/src/hooks/Context.js
@@ -30,12 +30,22 @@ var Q = require('q'),
* @param {Object} opts Hook options
* @returns {Object} */
function Context(hook, opts) {
+ var prop;
this.hook = hook;
- this.opts = opts;
+
+ //create new object, to avoid affecting input opts in other places
+ //For example context.opts.plugin = Object is done, then it affects by reference
+ this.opts = {};
+ for (prop in opts) {
+ if (opts.hasOwnProperty(prop)) {
+ this.opts[prop] = opts[prop];
+ }
+ }
this.cmdLine = process.argv.join(' ');
this.cordova = require('../cordova/cordova');
}
+
/**
* Returns a required module
* @param {String} path Module path
@@ -44,4 +54,4 @@ Context.prototype.requireCordovaModule = function (path) {
return require(path);
};
-module.exports = Context;
\ No newline at end of file
+module.exports = Context;