Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-5434

Android: require() in a non-root context breaks any include() statements below it.

    Details

      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:

      app.js

      Ti.UI.createWindow({
      	url: "win.js", // causes new JS context
      	backgroundColor: "#000",
      	exitOnClose: true
      }).open();
      

      And this win.js:

      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:

      module.js

      exports.x = function() {}; //not important
      

      And this included.js:

      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".

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                billdawson Bill Dawson
                Reporter:
                billdawson Bill Dawson
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-4606
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration