Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ask_for_reset for HTMLSelectElement. #7963

Merged
merged 11 commits into from Oct 28, 2015

Add fixes based on review.

- 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
commit 92e008307fe810ff9762d98b261e88f2040d1d5c
@@ -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();
}
}
}
@@ -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();
}
}

@@ -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()));
}
@@ -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>();
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.