mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
No retreievs item 0 when nothing is selected and return the proper value, or lable or content when item is selected
This commit is contained in:
parent
b0233d1ada
commit
593a8e8ba7
@ -488,11 +488,20 @@ nsHTMLSelectElement::GetValue(nsString& aValue)
|
||||
result = GetOptions(getter_AddRefs(options));
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
if (selectedIndex == -1) {
|
||||
selectedIndex = 0;
|
||||
}
|
||||
result = options->Item(selectedIndex, getter_AddRefs(node));
|
||||
if (NS_SUCCEEDED(result) && node) {
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> option = do_QueryInterface(node);
|
||||
if (option) {
|
||||
option->GetValue(aValue);
|
||||
if (0 == aValue.Length()) {
|
||||
option->GetLabel(aValue);
|
||||
if (0 == aValue.Length()) {
|
||||
option->GetText(aValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -488,11 +488,20 @@ nsHTMLSelectElement::GetValue(nsString& aValue)
|
||||
result = GetOptions(getter_AddRefs(options));
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
if (selectedIndex == -1) {
|
||||
selectedIndex = 0;
|
||||
}
|
||||
result = options->Item(selectedIndex, getter_AddRefs(node));
|
||||
if (NS_SUCCEEDED(result) && node) {
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> option = do_QueryInterface(node);
|
||||
if (option) {
|
||||
option->GetValue(aValue);
|
||||
if (0 == aValue.Length()) {
|
||||
option->GetLabel(aValue);
|
||||
if (0 == aValue.Length()) {
|
||||
option->GetText(aValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user