if (aIndex == (PRInt32)length) {
if (aIndex == mElements.Count()) {
nsHTMLOptionCollection::SetOption(PRInt32 aIndex,                                  nsIDOMHTMLOptionElement *aOption){  if (!mSelect) {    return NS_OK;  }  PRUint32 length;  nsresult rv = mElements->Count(&length);  // If the indx is within range  if ((aIndex >= 0) && (aIndex <= (PRInt32)length)) {    // if the new option is null, remove this option    if (!aOption) {      mSelect->Remove(aIndex);      // We're done.      return NS_OK;    }    nsCOMPtr<nsIDOMNode> ret;    if (aIndex == (PRInt32)length) {      rv = mSelect->AppendChild(aOption, getter_AddRefs(ret));    } else {      // Find the option they're talking about and replace it      nsCOMPtr<nsIDOMNode> refChild;      rv = mElements->QueryElementAt(aIndex,                                     NS_GET_IID(nsIDOMNode),                                     getter_AddRefs(refChild));      NS_ENSURE_TRUE(refChild, NS_ERROR_UNEXPECTED);      nsCOMPtr<nsIDOMNode> parent;      refChild->GetParentNode(getter_AddRefs(parent));      if (parent) {        rv = parent->ReplaceChild(aOption, refChild, getter_AddRefs(ret));      }    }  }  return rv;}