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

iOS: Ti.UI.View.children is not the empty array when no children are present

    Details

      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 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();
      
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ngupta Neeraj Gupta
                Reporter:
                stephentramer Stephen Tramer
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

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

                    Git Integration