nsHTMLOptionCollection::SetProperty(JSContext *aContext,
nsHTMLSelectElement::SetProperty(JSContext *aContext,
nsHTMLOptionCollection::SetProperty(JSContext *aContext,                           JSObject *aObj,                           jsval aID,                           jsval *aVp){  // XXX How about some error reporting and error  // propogation in this method???  if (JSVAL_IS_INT(aID) && (nsnull != mSelect)) {    PRInt32 indx = JSVAL_TO_INT(aID);    nsresult result;    // Update the options list    if (mDirty) {      GetOptions();    }        PRInt32 length = mElements.Count();    // If the indx is within range    if ((indx >= 0) && (indx <= length)) {      // if the value is null, remove this option      if (JSVAL_IS_NULL(*aVp)) {        mSelect->Remove(indx);      }      else {        JSObject* jsobj = JSVAL_TO_OBJECT(*aVp);         JSClass* jsclass = JS_GetClass(aContext, jsobj);        if ((nsnull != jsclass) && (jsclass->flags & JSCLASS_HAS_PRIVATE)) {          nsISupports *supports = (nsISupports *)JS_GetPrivate(aContext, jsobj);          nsIDOMNode* option;           nsIDOMNode* parent;          nsIDOMNode* refChild;          nsIDOMNode* ret;          if (NS_OK == supports->QueryInterface(kIDOMNodeIID, (void **)&option)) {            if (indx == length) {              result = mSelect->AppendChild(option, &ret);              NS_IF_RELEASE(ret);            }            else {              refChild = (nsIDOMNode*)mElements.ElementAt(indx);              if (nsnull != refChild) {                result = refChild->GetParentNode(&parent);                if (NS_SUCCEEDED(result) && (nsnull != parent)) {                                    result = parent->ReplaceChild(option, refChild, &ret);                  NS_IF_RELEASE(ret);                  NS_RELEASE(parent);                }              }                        }            NS_RELEASE(option);          }        }      }    }  }  return PR_TRUE;}