[TIMOB-8909] iOS: Ti.UI.View.children is not the empty array when no children are present
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-08-09T03:29:44.000+0000 |
Affected Version/s | Release 2.0.0 |
Fix Version/s | Release 2.1.0, Sprint 2012-09 Core |
Components | iOS |
Labels | core, module_views, qe-testadded |
Reporter | Stephen Tramer |
Assignee | Neeraj Gupta |
Created | 2012-04-27T17:50:21.000+0000 |
Updated | 2012-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();
Only depends on for testing.
Fixed by PR 2112
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
Re-opening to edit label