Skip to content

Commit

Permalink
Replace if-else with match.
Browse files Browse the repository at this point in the history
  • Loading branch information
dagnir committed Oct 25, 2015
1 parent fcfc391 commit b5e991c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions components/script/dom/htmlselectelement.rs
Expand Up @@ -70,16 +70,15 @@ impl HTMLSelectElement {
}
}

if last_selected.is_none() {
if self.display_size() == 1 {
// select the first enabled element
if let Some(first_opt) = first_enabled {
first_opt.set_selectedness(true);
match last_selected {
Some(last_selected) => last_selected.set_selectedness(true),
None => {
if self.display_size() == 1 {
if let Some(first_enabled) = first_enabled {
first_enabled.set_selectedness(true);
}
}
}
} else {
// >= 1 selected, reselect last one
last_selected.unwrap().set_selectedness(true);
}
}

Expand Down

0 comments on commit b5e991c

Please sign in to comment.