diff options
author | Corey Farwell <coreyf@rwell.org> | 2017-02-12 19:27:08 -0500 |
---|---|---|
committer | Corey Farwell <coreyf@rwell.org> | 2017-02-12 23:48:52 -0500 |
commit | d4ad51bfde796caf2f674b653a2717caaf6ecac2 (patch) | |
tree | e0cac7d94e46c0b466cc480beb4fa2e8fe811b06 /components/script/dom/htmloptionscollection.rs | |
parent | a656782075afb1fbc55e3f0f8bdb5a58010f3af3 (diff) | |
download | servo-d4ad51bfde796caf2f674b653a2717caaf6ecac2.tar.gz servo-d4ad51bfde796caf2f674b653a2717caaf6ecac2.zip |
Implement `selectedIndex` IDL attribute on `HTMLOptionsCollection`.
Diffstat (limited to 'components/script/dom/htmloptionscollection.rs')
-rw-r--r-- | components/script/dom/htmloptionscollection.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/components/script/dom/htmloptionscollection.rs b/components/script/dom/htmloptionscollection.rs index 2e4ce0f9a37..4fea7a69ff6 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}; @@ -16,6 +17,7 @@ use dom::bindings::str::DOMString; use dom::element::Element; use dom::htmlcollection::{CollectionFilter, HTMLCollection}; use dom::htmloptionelement::HTMLOptionElement; +use dom::htmlselectelement::HTMLSelectElement; use dom::node::{document_from_node, Node}; use dom::window::Window; @@ -182,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) + } } |