[TIMOB-5434] Android: require() in a non-root context breaks any include() statements below it.
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-01-09T13:48:17.000+0000 |
Affected Version/s | Release 1.8.0 |
Fix Version/s | Sprint 2011-42, Release 1.7.4, Release 1.8.0 |
Components | Android |
Labels | module_module, qe-testadded |
Reporter | Bill Dawson |
Assignee | Bill Dawson |
Created | 2011-10-04T18:26:18.000+0000 |
Updated | 2012-10-24T21:04:40.000+0000 |
Description
If an app has a second (or third, or fourth...) Javascript execution context (via a window being opened with a
url
property), a require()
statement anywhere in that context will break any include()
statements below it.
Reproduction of the failcase (and test of the fix):
In a new app use this app.js:
Ti.UI.createWindow({
url: "win.js", // causes new JS context
backgroundColor: "#000",
exitOnClose: true
}).open();
And this win.js:
require("module"); // Don't need return value, just important that this runs.
Ti.include("included.js");
alert("The included word is " + includedWord);
And this module.js:
exports.x = function() {}; //not important
And this included.js:
var includedWord = "test";
When you run that, you'll get an error in the failcase, saying that includedWord
is not defined.
When testing the fix, you should see an alert dialog telling you "The included word is test".
Pull request ready: https://github.com/appcelerator/titanium_mobile/pull/526
Closing. Passed as expected on Nexus One running 2.2.2 with SDK 1.8.0.v20111006001414.
Re-opening b/c will need to be re-tested with changes coming for TIMOB-5748
New pull request ready: https://github.com/appcelerator/titanium_mobile/pull/578
This problem is still occurring for me on 1.7.x (both 1.7.5 and the current 1.7.6 build as of Nov 10, 2011). I am including event handlers into a CommonJS module via Ti.include, but they're not showing up at runtime.
I take that back. The events get included. However, the included events refer to functions in the main (CommonJS) file, but it can't see them. I get an error "Cannot find function xxxx in object [object Object]".
Tested with 1.8.0.1.v20111205164258 v8/rhino on Galaxy 10.1 (3.1) Droid 1 (2.2.2) Nexus S (2.3.6) Emulator (4.0)
Added label: qe-testadded.