servo: Merge #3938 - Fix #3933 (from guillaumebort:fix/3933); r=jdm

Implement HTMLOptionElement.{label,value}

Source-Repo: https://github.com/servo/servo
Source-Revision: 668d9217d8b8d999547fd1e8b690da8c8d80ddda
This commit is contained in:
Guillaume Bort 2014-11-12 15:15:38 -07:00
Родитель 67f027d5e5
Коммит 7f266cc2c6
2 изменённых файлов: 33 добавлений и 4 удалений

Просмотреть файл

@ -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);
},
}
_ => ()
}
}

Просмотреть файл

@ -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;