Implement HTMLSelectElement.add() and indexed setter, fix test that was relying on add to be a stub

This commit is contained in:
Patrick Shaughnessy 2020-01-06 20:14:36 -05:00
parent 1d645f3741
commit c1b71fcc4d
7 changed files with 34 additions and 48 deletions

View file

@ -12,6 +12,7 @@ use crate::dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelec
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use crate::dom::bindings::codegen::UnionTypes::HTMLElementOrLong;
use crate::dom::bindings::codegen::UnionTypes::HTMLOptionElementOrHTMLOptGroupElement;
use crate::dom::bindings::error::ErrorResult;
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
use crate::dom::bindings::str::DOMString;
@ -203,13 +204,13 @@ impl HTMLSelectElementMethods for HTMLSelectElement {
ValidityState::new(&window, self.upcast())
}
// Note: this function currently only exists for union.html.
// https://html.spec.whatwg.org/multipage/#dom-select-add
fn Add(
&self,
_element: HTMLOptionElementOrHTMLOptGroupElement,
_before: Option<HTMLElementOrLong>,
) {
element: HTMLOptionElementOrHTMLOptGroupElement,
before: Option<HTMLElementOrLong>,
) -> ErrorResult {
self.Options().Add(element, before)
}
// https://html.spec.whatwg.org/multipage/#dom-fe-disabled
@ -281,6 +282,11 @@ impl HTMLSelectElementMethods for HTMLSelectElement {
self.Options().IndexedGetter(index)
}
// https://html.spec.whatwg.org/multipage/#dom-select-setter
fn IndexedSetter(&self, index: u32, value: Option<&HTMLOptionElement>) -> ErrorResult {
self.Options().IndexedSetter(index, value)
}
// https://html.spec.whatwg.org/multipage/#dom-select-nameditem
fn NamedItem(&self, name: DOMString) -> Option<DomRoot<HTMLOptionElement>> {
self.Options()