} else { res = mInner.SetProperty(aContext, aObj, aID, aVp);
PRInt32 length = mElements.Count();   if ((indx >= 0) && (indx <= length)) {   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); } } } }
nsHTMLSelectElement::SetProperty(JSContext *aContext,                           JSObject *aObj,                           jsval aID,                           jsval *aVp){  nsresult res = NS_OK;  // Set options in the options list by indexing into select  if (JSVAL_IS_INT(aID) && mOptions) {    nsIJSScriptObject* optList = nsnull;    res = mOptions->QueryInterface(kIJSScriptObjectIID, (void **)&optList);    if (NS_SUCCEEDED(res) && optList) {      res = optList->SetProperty(aContext, aObj, aID, aVp);      NS_RELEASE(optList);    }  } else {    res = mInner.SetProperty(aContext, aObj, aID, aVp);  }  return res;}