Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8909] iOS: Ti.UI.View.children is not the empty array when no children are present

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-08-09T03:29:44.000+0000
Affected Version/sRelease 2.0.0
Fix Version/sRelease 2.1.0, Sprint 2012-09 Core
ComponentsiOS
Labelscore, module_views, qe-testadded
ReporterStephen Tramer
AssigneeNeeraj Gupta
Created2012-04-27T17:50:21.000+0000
Updated2012-08-13T11:26:03.000+0000

Description

Currently, Android (and presumably mobileweb) return the empty array \[\] for Ti.UI.View.children when the view has no children. On iOS, we return undefined. Complicating matters is the fact that internally, we rely on this value for views with no children; this ticket could involve a substantial amount of work to ensure that no subsystems which rely on checking children content are affected.

Testing

---- Run the following test; it should not contain errors, but will only work after [pull request 2098](https://github.com/appcelerator/titanium_mobile/pull/2098) is processed.
var win = Ti.UI.createWindow();
 
function construct() {
    for (var i=0; i < 30; i++) {
        for (var j=0; j < 30; j++) {
            var bgcolor;
            switch (i % 3) {
                case 0:
                    bgcolor = 'red';
                    break;
                case 1:
                    bgcolor = 'blue';
                    break;
                case 2:
                    bgcolor = 'green';
                    break;
            }
            var view = Ti.UI.createView({
                top:(j*10),
                left:(i*10),
                width:10,
                height:10,
                backgroundColor:bgcolor
            });
            win.add(view);
            Ti.API.info('A '+win.children.length);
        }
    }
    setTimeout(destruct, 3000);
}
 
function destruct() {
	if (win.children.length > 0) 
    {
        Ti.API.info('B '+win.children.length);
        //Remove is a non blocking call so do it in a timed loop
        win.remove(win.children[0]);
        setTimeout(destruct,10);
    }
    else
    {
		setTimeout(construct, 3000);
    }
}

win.addEventListener('open',function(e){
	construct();
});

win.open();

Comments

  1. Stephen Tramer 2012-04-27

    Only depends on for testing.
  2. Vishal Duggal 2012-05-03

    Fixed by PR 2112
  3. Michael Pettiford 2012-06-14

    Closing issue Tested with Ti Studio build 2.1.0.201206131907 Ti Mobile SDK 2.1.0.v20120613210250 hash rc8ddb29e OSX Lion 10.7.3 iPhone 4S OS 5.1 The array is returned empty when there are not children. *QE port note* Move the info statement from the if statement in the destruct function to the else block
  4. Shyam Bhadauria 2012-08-09

    Re-opening to edit label

JSON Source