aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/htmloptionelement.rs31
-rw-r--r--components/script/dom/webidls/HTMLOptionElement.webidl6
2 files changed, 33 insertions, 4 deletions
diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs
index b9df3cc83d0..eabda88f4f8 100644
--- a/components/script/dom/htmloptionelement.rs
+++ b/components/script/dom/htmloptionelement.rs
@@ -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);
- },
+ }
_ => ()
}
}
diff --git a/components/script/dom/webidls/HTMLOptionElement.webidl b/components/script/dom/webidls/HTMLOptionElement.webidl
index 5c3f4b37f6a..9126e24d790 100644
--- a/components/script/dom/webidls/HTMLOptionElement.webidl
+++ b/components/script/dom/webidls/HTMLOptionElement.webidl
@@ -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;