This commit is contained in:
Guillaume Bort 2014-11-07 21:02:12 +01:00
parent bb7621f5dc
commit 09766511b5
7 changed files with 33 additions and 268 deletions

View file

@ -91,6 +91,35 @@ impl<'a> HTMLOptionElementMethods for JSRef<'a, HTMLOptionElement> {
let node: JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(self);
node.SetTextContent(Some(value)) node.SetTextContent(Some(value))
} }
// https://html.spec.whatwg.org/multipage/forms.html#attr-option-value
fn Value(self) -> DOMString {
let element: JSRef<Element> = ElementCast::from_ref(self);
let attr = &atom!("value");
if element.has_attribute(attr) {
element.get_string_attribute(attr)
} else {
self.Text()
}
}
// https://html.spec.whatwg.org/multipage/forms.html#attr-option-value
make_setter!(SetValue, "value")
// https://html.spec.whatwg.org/multipage/forms.html#attr-option-label
fn Label(self) -> DOMString {
let element: JSRef<Element> = ElementCast::from_ref(self);
let attr = &atom!("label");
if element.has_attribute(attr) {
element.get_string_attribute(attr)
} else {
self.Text()
}
}
// https://html.spec.whatwg.org/multipage/forms.html#attr-option-label
make_setter!(SetLabel, "label")
} }
impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> { impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
@ -110,7 +139,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
let node: JSRef<Node> = NodeCast::from_ref(*self); let node: JSRef<Node> = NodeCast::from_ref(*self);
node.set_disabled_state(true); node.set_disabled_state(true);
node.set_enabled_state(false); node.set_enabled_state(false);
}, }
_ => () _ => ()
} }
} }

View file

@ -6,12 +6,12 @@
// http://www.whatwg.org/html/#htmloptionelement // http://www.whatwg.org/html/#htmloptionelement
//[NamedConstructor=Option(optional DOMString text = "", optional DOMString value, optional boolean defaultSelected = false, optional boolean selected = false)] //[NamedConstructor=Option(optional DOMString text = "", optional DOMString value, optional boolean defaultSelected = false, optional boolean selected = false)]
interface HTMLOptionElement : HTMLElement { interface HTMLOptionElement : HTMLElement {
attribute boolean disabled; attribute boolean disabled;
//readonly attribute HTMLFormElement? form; //readonly attribute HTMLFormElement? form;
// attribute DOMString label; attribute DOMString label;
// attribute boolean defaultSelected; // attribute boolean defaultSelected;
// attribute boolean selected; // attribute boolean selected;
// attribute DOMString value; attribute DOMString value;
attribute DOMString text; attribute DOMString text;
//readonly attribute long index; //readonly attribute long index;

View file

@ -6135,36 +6135,24 @@
[HTMLOptionElement interface: attribute form] [HTMLOptionElement interface: attribute form]
expected: FAIL expected: FAIL
[HTMLOptionElement interface: attribute label]
expected: FAIL
[HTMLOptionElement interface: attribute defaultSelected] [HTMLOptionElement interface: attribute defaultSelected]
expected: FAIL expected: FAIL
[HTMLOptionElement interface: attribute selected] [HTMLOptionElement interface: attribute selected]
expected: FAIL expected: FAIL
[HTMLOptionElement interface: attribute value]
expected: FAIL
[HTMLOptionElement interface: attribute index] [HTMLOptionElement interface: attribute index]
expected: FAIL expected: FAIL
[HTMLOptionElement interface: document.createElement("option") must inherit property "form" with the proper type (1)] [HTMLOptionElement interface: document.createElement("option") must inherit property "form" with the proper type (1)]
expected: FAIL expected: FAIL
[HTMLOptionElement interface: document.createElement("option") must inherit property "label" with the proper type (2)]
expected: FAIL
[HTMLOptionElement interface: document.createElement("option") must inherit property "defaultSelected" with the proper type (3)] [HTMLOptionElement interface: document.createElement("option") must inherit property "defaultSelected" with the proper type (3)]
expected: FAIL expected: FAIL
[HTMLOptionElement interface: document.createElement("option") must inherit property "selected" with the proper type (4)] [HTMLOptionElement interface: document.createElement("option") must inherit property "selected" with the proper type (4)]
expected: FAIL expected: FAIL
[HTMLOptionElement interface: document.createElement("option") must inherit property "value" with the proper type (5)]
expected: FAIL
[HTMLOptionElement interface: document.createElement("option") must inherit property "index" with the proper type (7)] [HTMLOptionElement interface: document.createElement("option") must inherit property "index" with the proper type (7)]
expected: FAIL expected: FAIL

View file

@ -13527,93 +13527,6 @@
[option.tabIndex: IDL set to -2147483648 followed by getAttribute()] [option.tabIndex: IDL set to -2147483648 followed by getAttribute()]
expected: FAIL expected: FAIL
[option.label: typeof IDL attribute]
expected: FAIL
[option.label: IDL get with DOM attribute unset]
expected: FAIL
[option.label: IDL set to "" followed by getAttribute()]
expected: FAIL
[option.label: IDL set to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo " followed by getAttribute()]
expected: FAIL
[option.label: IDL set to undefined followed by getAttribute()]
expected: FAIL
[option.label: IDL set to undefined followed by IDL get]
expected: FAIL
[option.label: IDL set to 7 followed by getAttribute()]
expected: FAIL
[option.label: IDL set to 7 followed by IDL get]
expected: FAIL
[option.label: IDL set to 1.5 followed by getAttribute()]
expected: FAIL
[option.label: IDL set to 1.5 followed by IDL get]
expected: FAIL
[option.label: IDL set to true followed by getAttribute()]
expected: FAIL
[option.label: IDL set to true followed by IDL get]
expected: FAIL
[option.label: IDL set to false followed by getAttribute()]
expected: FAIL
[option.label: IDL set to false followed by IDL get]
expected: FAIL
[option.label: IDL set to object "[object Object\]" followed by getAttribute()]
expected: FAIL
[option.label: IDL set to object "[object Object\]" followed by IDL get]
expected: FAIL
[option.label: IDL set to NaN followed by getAttribute()]
expected: FAIL
[option.label: IDL set to NaN followed by IDL get]
expected: FAIL
[option.label: IDL set to Infinity followed by getAttribute()]
expected: FAIL
[option.label: IDL set to Infinity followed by IDL get]
expected: FAIL
[option.label: IDL set to -Infinity followed by getAttribute()]
expected: FAIL
[option.label: IDL set to -Infinity followed by IDL get]
expected: FAIL
[option.label: IDL set to "\\0" followed by getAttribute()]
expected: FAIL
[option.label: IDL set to null followed by getAttribute()]
expected: FAIL
[option.label: IDL set to null followed by IDL get]
expected: FAIL
[option.label: IDL set to object "test-toString" followed by getAttribute()]
expected: FAIL
[option.label: IDL set to object "test-toString" followed by IDL get]
expected: FAIL
[option.label: IDL set to object "test-valueOf" followed by getAttribute()]
expected: FAIL
[option.label: IDL set to object "test-valueOf" followed by IDL get]
expected: FAIL
[option.defaultSelected (<option selected>): typeof IDL attribute] [option.defaultSelected (<option selected>): typeof IDL attribute]
expected: FAIL expected: FAIL
@ -13722,93 +13635,6 @@
[option.defaultSelected (<option selected>): IDL set to object "test-valueOf" followed by IDL get] [option.defaultSelected (<option selected>): IDL set to object "test-valueOf" followed by IDL get]
expected: FAIL expected: FAIL
[option.value: typeof IDL attribute]
expected: FAIL
[option.value: IDL get with DOM attribute unset]
expected: FAIL
[option.value: IDL set to "" followed by getAttribute()]
expected: FAIL
[option.value: IDL set to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo " followed by getAttribute()]
expected: FAIL
[option.value: IDL set to undefined followed by getAttribute()]
expected: FAIL
[option.value: IDL set to undefined followed by IDL get]
expected: FAIL
[option.value: IDL set to 7 followed by getAttribute()]
expected: FAIL
[option.value: IDL set to 7 followed by IDL get]
expected: FAIL
[option.value: IDL set to 1.5 followed by getAttribute()]
expected: FAIL
[option.value: IDL set to 1.5 followed by IDL get]
expected: FAIL
[option.value: IDL set to true followed by getAttribute()]
expected: FAIL
[option.value: IDL set to true followed by IDL get]
expected: FAIL
[option.value: IDL set to false followed by getAttribute()]
expected: FAIL
[option.value: IDL set to false followed by IDL get]
expected: FAIL
[option.value: IDL set to object "[object Object\]" followed by getAttribute()]
expected: FAIL
[option.value: IDL set to object "[object Object\]" followed by IDL get]
expected: FAIL
[option.value: IDL set to NaN followed by getAttribute()]
expected: FAIL
[option.value: IDL set to NaN followed by IDL get]
expected: FAIL
[option.value: IDL set to Infinity followed by getAttribute()]
expected: FAIL
[option.value: IDL set to Infinity followed by IDL get]
expected: FAIL
[option.value: IDL set to -Infinity followed by getAttribute()]
expected: FAIL
[option.value: IDL set to -Infinity followed by IDL get]
expected: FAIL
[option.value: IDL set to "\\0" followed by getAttribute()]
expected: FAIL
[option.value: IDL set to null followed by getAttribute()]
expected: FAIL
[option.value: IDL set to null followed by IDL get]
expected: FAIL
[option.value: IDL set to object "test-toString" followed by getAttribute()]
expected: FAIL
[option.value: IDL set to object "test-toString" followed by IDL get]
expected: FAIL
[option.value: IDL set to object "test-valueOf" followed by getAttribute()]
expected: FAIL
[option.value: IDL set to object "test-valueOf" followed by IDL get]
expected: FAIL
[option.itemScope: typeof IDL attribute] [option.itemScope: typeof IDL attribute]
expected: FAIL expected: FAIL

View file

@ -1,7 +1,5 @@
[datalistoptions.html] [datalistoptions.html]
type: testharness type: testharness
[options label/value]
expected: FAIL
[If an element has a datalist element ancestor, it is barred from constraint validation] [If an element has a datalist element ancestor, it is barred from constraint validation]
expected: FAIL expected: FAIL

View file

@ -1,38 +0,0 @@
[option-label.html]
type: testharness
[No children, no label]
expected: FAIL
[No children, empty label]
expected: FAIL
[No children, label]
expected: FAIL
[No children, namespaced label]
expected: FAIL
[Single child, no label]
expected: FAIL
[Single child, empty label]
expected: FAIL
[Single child, label]
expected: FAIL
[Single child, namespaced label]
expected: FAIL
[Two children, no label]
expected: FAIL
[Two children, empty label]
expected: FAIL
[Two children, label]
expected: FAIL
[Two children, namespaced label]
expected: FAIL

View file

@ -1,38 +0,0 @@
[option-value.html]
type: testharness
[No children, no value]
expected: FAIL
[No children, empty value]
expected: FAIL
[No children, value]
expected: FAIL
[No children, namespaced value]
expected: FAIL
[Single child, no value]
expected: FAIL
[Single child, empty value]
expected: FAIL
[Single child, value]
expected: FAIL
[Single child, namespaced value]
expected: FAIL
[Two children, no value]
expected: FAIL
[Two children, empty value]
expected: FAIL
[Two children, value]
expected: FAIL
[Two children, namespaced value]
expected: FAIL