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);
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> {
@ -110,7 +139,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
let node: JSRef<Node> = NodeCast::from_ref(*self);
node.set_disabled_state(true);
node.set_enabled_state(false);
},
}
_ => ()
}
}

View file

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