Skip to content

Commit

Permalink
Add fixes based on review.
Browse files Browse the repository at this point in the history
- Whitespace and indentation issues

- call as_for_reset on option insert

- add link to 'pick' in standard
  • Loading branch information
dagnir committed Oct 27, 2015
1 parent 15a8b6b commit 92e0083
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
20 changes: 10 additions & 10 deletions components/script/dom/htmloptionelement.rs
Expand Up @@ -140,11 +140,11 @@ impl HTMLOptionElementMethods for HTMLOptionElement {
self.dirtiness.set(true);
self.selectedness.set(selected);
if let Some(select) = self.upcast::<Node>().ancestors()
.filter_map(Root::downcast::<HTMLSelectElement>).next() {
if selected {
select.pick_option(self);
}
select.ask_for_reset();
.filter_map(Root::downcast::<HTMLSelectElement>).next() {
if selected {
select.pick_option(self);
}
select.ask_for_reset();
}
}
}
Expand Down Expand Up @@ -198,13 +198,13 @@ impl VirtualMethods for HTMLOptionElement {

self.upcast::<Element>().check_parent_disabled_state_for_option();

if self.Selected() {
let node = self.upcast::<Node>();
if let Some(select) = node.ancestors()
.filter_map(Root::downcast::<HTMLSelectElement>)
.next() {
if let Some(select) = self.upcast::<Node>().ancestors()
.filter_map(Root::downcast::<HTMLSelectElement>)
.next() {
if self.Selected() {
select.pick_option(self);
}
select.ask_for_reset();
}
}

Expand Down
3 changes: 2 additions & 1 deletion components/script/dom/htmlselectelement.rs
Expand Up @@ -64,7 +64,7 @@ impl HTMLSelectElement {
opt.set_selectedness(false);
last_selected = Some(Root::from_ref(opt.r()));
}
let element = opt.upcast::<Element>();
let element = opt.upcast::<Element>();
if first_enabled.is_none() && !element.get_disabled_state() {
first_enabled = Some(Root::from_ref(opt.r()));
}
Expand All @@ -82,6 +82,7 @@ impl HTMLSelectElement {
}
}

// https://html.spec.whatwg.org/multipage/#concept-select-pick
pub fn pick_option(&self, picked: &HTMLOptionElement) {
if !self.Multiple() {
let node = self.upcast::<Node>();
Expand Down

0 comments on commit 92e0083

Please sign in to comment.