Add fixes based on review.

- Whitespace and indentation issues

- call as_for_reset on option insert

- add link to 'pick' in standard
This commit is contained in:
Dongie Agnir 2015-10-27 11:52:55 -10:00
parent 15a8b6b62c
commit 92e008307f
2 changed files with 12 additions and 11 deletions

View file

@ -140,11 +140,11 @@ impl HTMLOptionElementMethods for HTMLOptionElement {
self.dirtiness.set(true); self.dirtiness.set(true);
self.selectedness.set(selected); self.selectedness.set(selected);
if let Some(select) = self.upcast::<Node>().ancestors() if let Some(select) = self.upcast::<Node>().ancestors()
.filter_map(Root::downcast::<HTMLSelectElement>).next() { .filter_map(Root::downcast::<HTMLSelectElement>).next() {
if selected { if selected {
select.pick_option(self); select.pick_option(self);
} }
select.ask_for_reset(); select.ask_for_reset();
} }
} }
} }
@ -198,13 +198,13 @@ impl VirtualMethods for HTMLOptionElement {
self.upcast::<Element>().check_parent_disabled_state_for_option(); self.upcast::<Element>().check_parent_disabled_state_for_option();
if self.Selected() { if let Some(select) = self.upcast::<Node>().ancestors()
let node = self.upcast::<Node>(); .filter_map(Root::downcast::<HTMLSelectElement>)
if let Some(select) = node.ancestors() .next() {
.filter_map(Root::downcast::<HTMLSelectElement>) if self.Selected() {
.next() {
select.pick_option(self); select.pick_option(self);
} }
select.ask_for_reset();
} }
} }

View file

@ -64,7 +64,7 @@ impl HTMLSelectElement {
opt.set_selectedness(false); opt.set_selectedness(false);
last_selected = Some(Root::from_ref(opt.r())); 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() { if first_enabled.is_none() && !element.get_disabled_state() {
first_enabled = Some(Root::from_ref(opt.r())); first_enabled = Some(Root::from_ref(opt.r()));
} }
@ -82,6 +82,7 @@ impl HTMLSelectElement {
} }
} }
// https://html.spec.whatwg.org/multipage/#concept-select-pick
pub fn pick_option(&self, picked: &HTMLOptionElement) { pub fn pick_option(&self, picked: &HTMLOptionElement) {
if !self.Multiple() { if !self.Multiple() {
let node = self.upcast::<Node>(); let node = self.upcast::<Node>();