The index of the option being deleted needs to be remembered before the it is removed from the list

This commit is contained in:
rods@netscape.com
1999-08-25 13:44:49 +00:00
parent 5b644e2d13
commit 665455a67b
2 changed files with 6 additions and 2 deletions
@@ -676,6 +676,8 @@ nsHTMLSelectElement::RemoveOption(nsIContent* aContent)
// as we will manually update the widget at frame construction time.
if (!mOptions) return NS_OK;
PRInt32 oldIndex = mOptions->IndexOf(aContent);
// Remove the option from the options list
mOptions->RemoveOption(aContent);
@@ -689,7 +691,7 @@ nsHTMLSelectElement::RemoveOption(nsIContent* aContent)
// We can't get our index if we've already been replaced in the OptionList.
// If we couldn't get our index, pass -1, remove all options and recreate
// Coincidentally, IndexOf returns -1 if the option isn't found in the list
result = selectFrame->RemoveOption(mOptions->IndexOf(aContent));
result = selectFrame->RemoveOption(oldIndex);
}
}