mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Implement HTMLSelectElement.add() and indexed setter, fix test that was relying on add to be a stub
This commit is contained in:
parent
1d645f3741
commit
c1b71fcc4d
7 changed files with 34 additions and 48 deletions
|
@ -5263,7 +5263,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
||||||
CGIndenter(CGProxyNamedSetter(self.descriptor)).define() +
|
CGIndenter(CGProxyNamedSetter(self.descriptor)).define() +
|
||||||
" return (*opresult).succeed();\n" +
|
" return (*opresult).succeed();\n" +
|
||||||
"}\n")
|
"}\n")
|
||||||
else:
|
elif self.descriptor.operations['NamedGetter']:
|
||||||
set += ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n" +
|
set += ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n" +
|
||||||
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() +
|
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() +
|
||||||
" if result.is_some() {\n"
|
" 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::Bindings::NodeBinding::NodeMethods;
|
||||||
use crate::dom::bindings::codegen::UnionTypes::HTMLElementOrLong;
|
use crate::dom::bindings::codegen::UnionTypes::HTMLElementOrLong;
|
||||||
use crate::dom::bindings::codegen::UnionTypes::HTMLOptionElementOrHTMLOptGroupElement;
|
use crate::dom::bindings::codegen::UnionTypes::HTMLOptionElementOrHTMLOptGroupElement;
|
||||||
|
use crate::dom::bindings::error::ErrorResult;
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
|
@ -203,13 +204,13 @@ impl HTMLSelectElementMethods for HTMLSelectElement {
|
||||||
ValidityState::new(&window, self.upcast())
|
ValidityState::new(&window, self.upcast())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: this function currently only exists for union.html.
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-select-add
|
// https://html.spec.whatwg.org/multipage/#dom-select-add
|
||||||
fn Add(
|
fn Add(
|
||||||
&self,
|
&self,
|
||||||
_element: HTMLOptionElementOrHTMLOptGroupElement,
|
element: HTMLOptionElementOrHTMLOptGroupElement,
|
||||||
_before: Option<HTMLElementOrLong>,
|
before: Option<HTMLElementOrLong>,
|
||||||
) {
|
) -> ErrorResult {
|
||||||
|
self.Options().Add(element, before)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-fe-disabled
|
// https://html.spec.whatwg.org/multipage/#dom-fe-disabled
|
||||||
|
@ -281,6 +282,11 @@ impl HTMLSelectElementMethods for HTMLSelectElement {
|
||||||
self.Options().IndexedGetter(index)
|
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
|
// https://html.spec.whatwg.org/multipage/#dom-select-nameditem
|
||||||
fn NamedItem(&self, name: DOMString) -> Option<DomRoot<HTMLOptionElement>> {
|
fn NamedItem(&self, name: DOMString) -> Option<DomRoot<HTMLOptionElement>> {
|
||||||
self.Options()
|
self.Options()
|
||||||
|
|
|
@ -28,15 +28,14 @@ interface HTMLSelectElement : HTMLElement {
|
||||||
attribute unsigned long length;
|
attribute unsigned long length;
|
||||||
getter Element? item(unsigned long index);
|
getter Element? item(unsigned long index);
|
||||||
HTMLOptionElement? namedItem(DOMString name);
|
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);
|
void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
void remove(); // ChildNode overload
|
void remove(); // ChildNode overload
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
void remove(long index);
|
void remove(long index);
|
||||||
// [CEReactions]
|
[CEReactions, Throws] setter void (unsigned long index, HTMLOptionElement? option);
|
||||||
// setter void (unsigned long index, HTMLOptionElement? option);
|
|
||||||
|
|
||||||
// readonly attribute HTMLCollection selectedOptions;
|
// readonly attribute HTMLCollection selectedOptions;
|
||||||
attribute long selectedIndex;
|
attribute long selectedIndex;
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
[HTMLSelectElement.html]
|
|
||||||
type: testharness
|
|
||||||
[The indexed setter on HTMLSelectElement must enqueue connectedCallback when inserting a custom element]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[The indexed setter on HTMLSelectElement must enqueue disconnectedCallback when removing a custom element]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[add on HTMLSelectElement must enqueue connectedCallback when inserting a custom element]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Custom Elements: CEReactions on HTMLSelectElement interface]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
[select-add.html]
|
|
||||||
[test that HTMLSelectElement.add method can add option element]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[test that HierarchyRequestError exception must be thrown when element is an ancestor of the element into which it is to be inserted]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -827,6 +827,18 @@
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
"css/border_black_groove.html": [
|
||||||
|
[
|
||||||
|
"css/border_black_groove.html",
|
||||||
|
[
|
||||||
|
[
|
||||||
|
"/_mozilla/css/border_black_solid.html",
|
||||||
|
"!="
|
||||||
|
]
|
||||||
|
],
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
],
|
||||||
"css/border_black_ridge_a.html": [
|
"css/border_black_ridge_a.html": [
|
||||||
[
|
[
|
||||||
"css/border_black_ridge_a.html",
|
"css/border_black_ridge_a.html",
|
||||||
|
@ -7662,20 +7674,6 @@
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"reftest_node": {
|
|
||||||
"css/border_black_groove.html": [
|
|
||||||
[
|
|
||||||
"css/border_black_groove.html",
|
|
||||||
[
|
|
||||||
[
|
|
||||||
"/_mozilla/css/border_black_solid.html",
|
|
||||||
"!="
|
|
||||||
]
|
|
||||||
],
|
|
||||||
{}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"support": {
|
"support": {
|
||||||
".gitignore": [
|
".gitignore": [
|
||||||
[]
|
[]
|
||||||
|
@ -14053,7 +14051,7 @@
|
||||||
],
|
],
|
||||||
"css/border_black_groove.html": [
|
"css/border_black_groove.html": [
|
||||||
"49e1647a6f71e320770225ad537b4fd4020bd700",
|
"49e1647a6f71e320770225ad537b4fd4020bd700",
|
||||||
"reftest_node"
|
"reftest"
|
||||||
],
|
],
|
||||||
"css/border_black_ridge_a.html": [
|
"css/border_black_ridge_a.html": [
|
||||||
"90cdda1dca8793a1c01b72f1ad27398903cfd823",
|
"90cdda1dca8793a1c01b72f1ad27398903cfd823",
|
||||||
|
@ -19552,7 +19550,7 @@
|
||||||
"testharness"
|
"testharness"
|
||||||
],
|
],
|
||||||
"mozilla/union.html": [
|
"mozilla/union.html": [
|
||||||
"42012add68c355c81e793492e59b05c1ca728f2d",
|
"dec25d03b8e46791c8044c67bca93036c3e8bdeb",
|
||||||
"testharness"
|
"testharness"
|
||||||
],
|
],
|
||||||
"mozilla/unitless-length.html": [
|
"mozilla/unitless-length.html": [
|
||||||
|
|
|
@ -6,14 +6,18 @@
|
||||||
<script>
|
<script>
|
||||||
test(function() {
|
test(function() {
|
||||||
var div = document.createElement('div');
|
var div = document.createElement('div');
|
||||||
|
var div2 = document.createElement('div');
|
||||||
var optgroup = document.createElement('optgroup');
|
var optgroup = document.createElement('optgroup');
|
||||||
var sel = document.getElementById('sel');
|
var sel = document.getElementById('sel');
|
||||||
|
sel.appendChild(div2);
|
||||||
|
|
||||||
var opt = document.createElement('option');
|
var opt = document.createElement('option');
|
||||||
sel.add(opt);
|
sel.add(opt);
|
||||||
sel.add(optgroup);
|
sel.add(optgroup);
|
||||||
sel.add(opt, div);
|
assert_throws("NotFoundError", function() { sel.add(opt, div); });
|
||||||
sel.add(optgroup, div);
|
assert_throws("NotFoundError", function() { sel.add(optgroup, div); });
|
||||||
|
sel.add(opt, div2);
|
||||||
|
sel.add(optgroup, div2);
|
||||||
sel.add(opt, 5);
|
sel.add(opt, 5);
|
||||||
sel.add(optgroup, 5);
|
sel.add(optgroup, 5);
|
||||||
assert_throws(new TypeError(), function() { sel.add(div) });
|
assert_throws(new TypeError(), function() { sel.add(div) });
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue