mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Auto merge of #25449 - pshaughn:select-adding, r=Manishearth
Implement HTMLSelectElement.add() and indexed setter HTMLSelectElement.add and its indexed setter just needed to forward to matching methods in HTMLOptionsCollection, which they now do. It was also necessary to change codegen slightly; it had accidentally assumed that if an indexed setter existed, a named getter or setter also would. I expect this and #25446 will combine to pass more tests than either alone does. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #25003 <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
1e7c206ac4
7 changed files with 34 additions and 48 deletions
|
@ -5263,7 +5263,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
|||
CGIndenter(CGProxyNamedSetter(self.descriptor)).define() +
|
||||
" return (*opresult).succeed();\n" +
|
||||
"}\n")
|
||||
else:
|
||||
elif self.descriptor.operations['NamedGetter']:
|
||||
set += ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n" +
|
||||
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() +
|
||||
" if result.is_some() {\n"
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -28,15 +28,14 @@ interface HTMLSelectElement : HTMLElement {
|
|||
attribute unsigned long length;
|
||||
getter Element? item(unsigned long index);
|
||||
HTMLOptionElement? namedItem(DOMString name);
|
||||
// Note: this function currently only exists for union.html.
|
||||
[CEReactions]
|
||||
|
||||
[CEReactions, Throws]
|
||||
void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
|
||||
[CEReactions]
|
||||
void remove(); // ChildNode overload
|
||||
[CEReactions]
|
||||
void remove(long index);
|
||||
// [CEReactions]
|
||||
// setter void (unsigned long index, HTMLOptionElement? option);
|
||||
[CEReactions, Throws] setter void (unsigned long index, HTMLOptionElement? option);
|
||||
|
||||
// readonly attribute HTMLCollection selectedOptions;
|
||||
attribute long selectedIndex;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue