rem: for (var i=0; i<userDefinedItems.length; i++) 
add: for (var i=0; userDefinedItems.item(i); ) 
context: function viewRefreshCustomMailViews(aCurrentViewValue){  // for each mail view in the msg view list, add a menu item  var mailViewList = Components.classes["@mozilla.org/messenger/mailviewlist;1"].getService(Components.interfaces.nsIMsgMailViewList);  // XXX TODO, fix code in msgViewPickerOverlay.js, to be like this.  // remove any existing entries...  var menupopupNode = document.getElementById('viewMessageViewPopup');  var userDefinedItems = menupopupNode.getElementsByAttribute("userdefined","true");  for (var i=0; i<userDefinedItems.length; i++)  {    menupopupNode.removeChild(userDefinedItems[i]);  }    // now rebuild the list  var numItems = mailViewList.mailViewCount;   var viewCreateCustomViewSeparator = document.getElementById('viewCreateCustomViewSeparator');    for (i = 0; i < numItems; i++)  {    var newMenuItem = document.createElement("menuitem");    newMenuItem.setAttribute("label", mailViewList.getMailViewAt(i).mailViewName);    newMenuItem.setAttribute("userdefined", "true");    var oncommandStr = "ViewMessagesBy('userdefinedview" + (kLastDefaultViewIndex + i) + "');";      newMenuItem.setAttribute("oncommand", oncommandStr);    var item = menupopupNode.insertBefore(newMenuItem, viewCreateCustomViewSeparator);    item.setAttribute("value",  kLastDefaultViewIndex + i);     item.setAttribute("type",  "radio"); // for checked    item.setAttribute("name", "viewmessages");  // for checked    item.setAttribute("checked", (kLastDefaultViewIndex + i == aCurrentViewValue));   }  if (!numItems)    viewCreateCustomViewSeparator.setAttribute('collapsed', true);  else    viewCreateCustomViewSeparator.removeAttribute('collapsed');}
meta: 10234	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/10234/7a84ac3af7b1c9fc30aa77c4433da9479bb4c400/mailWindowOverlay.js/buggy/mailnews/base/resources/content/mailWindowOverlay.js