mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Implement selectedIndex
IDL attribute on HTMLOptionsCollection
.
This commit is contained in:
parent
a656782075
commit
d4ad51bfde
5 changed files with 65 additions and 24 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue