aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmloptionscollection.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-02-19 03:08:12 -0800
committerGitHub <noreply@github.com>2017-02-19 03:08:12 -0800
commit5f813233c9e2b51497c1e5fe4bc10ffd641a3b5e (patch)
tree8b2de31a33591941533f05ef3af7ba94bec6bb91 /components/script/dom/htmloptionscollection.rs
parent5c73b374cb7e41b33e076c3e04fe30b1eb91e7b1 (diff)
parentd4ad51bfde796caf2f674b653a2717caaf6ecac2 (diff)
downloadservo-5f813233c9e2b51497c1e5fe4bc10ffd641a3b5e.tar.gz
servo-5f813233c9e2b51497c1e5fe4bc10ffd641a3b5e.zip
Auto merge of #15520 - frewsxcv:html-options-collection-selected-index, r=nox
Implement `selectedIndex` IDL attribute on `HTMLOptionsCollection`. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15520) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/htmloptionscollection.rs')
-rw-r--r--components/script/dom/htmloptionscollection.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/components/script/dom/htmloptionscollection.rs b/components/script/dom/htmloptionscollection.rs
index 95478fc30f3..be7031ab8d0 100644
--- a/components/script/dom/htmloptionscollection.rs
+++ b/components/script/dom/htmloptionscollection.rs
@@ -6,6 +6,7 @@ use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
use dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods;
use dom::bindings::codegen::Bindings::HTMLOptionsCollectionBinding;
use dom::bindings::codegen::Bindings::HTMLOptionsCollectionBinding::HTMLOptionsCollectionMethods;
+use dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementMethods;
use dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods;
use dom::bindings::codegen::UnionTypes::{HTMLOptionElementOrHTMLOptGroupElement, HTMLElementOrLong};
use dom::bindings::error::{Error, ErrorResult};
@@ -183,4 +184,22 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection {
element.Remove();
}
}
+
+ // https://html.spec.whatwg.org/multipage/#dom-htmloptionscollection-selectedindex
+ fn SelectedIndex(&self) -> i32 {
+ self.upcast()
+ .root_node()
+ .downcast::<HTMLSelectElement>()
+ .expect("HTMLOptionsCollection not rooted on a HTMLSelectElement")
+ .SelectedIndex()
+ }
+
+ // https://html.spec.whatwg.org/multipage/#dom-htmloptionscollection-selectedindex
+ fn SetSelectedIndex(&self, index: i32) {
+ self.upcast()
+ .root_node()
+ .downcast::<HTMLSelectElement>()
+ .expect("HTMLOptionsCollection not rooted on a HTMLSelectElement")
+ .SetSelectedIndex(index)
+ }
}