[TIMOB-20141] Global scope variables can be shared with CommonJS modules
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-01-06T15:29:00.000+0000 |
Affected Version/s | Release 5.1.1 |
Fix Version/s | Release 9.0.0 |
Components | n/a |
Labels | engSchedule, ios, iphone |
Reporter | Eric |
Assignee | Ewan Harris |
Created | 2015-02-03T17:31:49.000+0000 |
Updated | 2020-01-06T15:29:00.000+0000 |
Description
module.js
console.log(controllerVariable);
moduleVariable = "moduleVariable";
module.exports = {};
controller.js
controllerVariable = "controllerVariable";
var module = require("module");
console.log(moduleVariable);
Output when running the application is:
moduleVariable
controllerVariable
Expected that the global scope of the controller would not be shared with the global scope of the module.
Hello, please read the guide to report issues: http://docs.appcelerator.com/titanium/3.0/#!/guide/How_to_Submit_a_Bug_Report and provide at least: - Description of the problem - Steps to reproduce - Expected Results - Actual Results If you want/need to add a new feature, explain what you need, why you need it, and what you expect to be a solution.
Description of the problem: Global scope variables can be shared with CommonJS modules Steps to reproduce: 1) Here is the source for the module: module.js
2) Here is the source for the controller: controller.js
Actual results (console output): moduleVariable controllerVariable Expected results (neither variable should be defined in the scope it is logged): undefined undefined If it was strict mode, I would expect an exception for not finding the variables. What other information is necessary so that I can provide it to you? This was all in the original report.
node-titanium-sdk PR: https://github.com/appcelerator/node-titanium-sdk/pull/129
merged the node-titanium-sdk PR, once 4.0.0 goes out we'll need to fold that into the SDK
merged to master for 9.0.0: https://github.com/appcelerator/titanium_mobile/pull/11387