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

Syntax eval is not working inside the CommonJS module.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: iOS
    • Labels:
      None
    • Environment:

      Ti SDK version: 6.2.2
      Node: 6.11.4
      iOS device 5s v11.0.3

    • Story Points:
      5
    • Sprint:
      2017 Sprint 23 SDK

      Description

      JavaScript eval() function is not working inside the CommonJS module and the iOS device. It can not detect the variable value when we write down inside the CommonJS module. But it works if we write eval() function to the app.js file.

      Steps to Reproduce:

      1. Create a new App
      2. Disable LiveView
      3. Run the following test code on the iOS device

      Note: It works if liveveiw is enabled. Also, working in a simulator.

      app.js

      var win = Ti.UI.createWindow({
      	backgroundColor : 'red',
      	layout : "vertical"
      });
       
      // Create a Button.
      var request = Ti.UI.createButton({
      	title : 'Got it',
      	height : Ti.UI.SIZE,
      	width : Ti.UI.SIZE,
      	top : 50
      });
       
       
      request.addEventListener('click', function(e) {
       
      	var EvalTestClass = require('lib/evalTest');
       
      	var evalTest = new EvalTestClass();
       
      	evalTest.open();
      });
       
      win.add(request);
       
      win.open();
       
       
      
      

      evalTest

      function view() {
       
      	var win = Ti.UI.createWindow({
      		title : "Test",
      		backgroundColor : '#fff'
      	});
       
      	var X = 10;
      	var Y = 20;
       
      	function iWantToKillMyslef() {
      		alert("This works in the Simulator and in Live View");
      	}
       
      	var a = eval("X*Y");
       
      	var label = Ti.UI.createLabel({
      		text : a,
      		color : "#333",
      		font : {
      			fontSize : 20
      		}
      	});
      	win.add(label);
       
      	try {
      		eval("iWantToKillMyslef()");
      	} catch (e) {
      		alert(e);
      	}
       
      	return win;
      };
       
      module.exports = view;
       
      
      

      Error Code

      [ERROR] :  Script Error {
      [ERROR] :      column = 2;
      [ERROR] :      line = 1;
      [ERROR] :      message = "Can't find variable: X";
      [ERROR] :      stack = "eval code\neval@[native code]\nview@file:///var/containers/Bundle/Application/A4AEE4ED-3CBA-4F93-9E91-A3E4ACE80496/EvalTest.app/lib/evalTest.js:1:287\nfile:///var/containers/Bundle/Application/A4AEE4ED-3CBA-4F93-9E91-A3E4ACE80496/EvalTest.app/app.js:1:276";
      [ERROR] :  }
      
      

      Thanks

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hknoechel Hans Knöchel
                Reporter:
                lau.yikonn lau.yikonn
              • Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

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

                    Git Source Code