diff options
author | Matthew Rasmus <mattr@zzntd.com> | 2014-12-07 10:33:20 -0800 |
---|---|---|
committer | Matthew Rasmus <mattr@zzntd.com> | 2014-12-16 11:34:04 -0800 |
commit | a3b3295d80194becf83f153e480df7f19c3e2971 (patch) | |
tree | 1398e5b7d42854fc646eb71adc0711fe0bce4b16 /components/script/dom/htmlformelement.rs | |
parent | f0ce2af89ce264ddb707c67822ae1f4e4fb622e8 (diff) | |
download | servo-a3b3295d80194becf83f153e480df7f19c3e2971.tar.gz servo-a3b3295d80194becf83f153e480df7f19c3e2971.zip |
Adds reset method to FormControl
Diffstat (limited to 'components/script/dom/htmlformelement.rs')
-rw-r--r-- | components/script/dom/htmlformelement.rs | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index a08b8eec270..8f5b0180c02 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -346,32 +346,17 @@ impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> { // TODO: This is an incorrect way of getting controls owned // by the form, but good enough until html5ever lands for child in node.traverse_preorder() { - // TODO This is the wrong place to do this. Each resettable - // element should implement its own reset method (trait?) - // - // List of resettable elements: - // https://html.spec.whatwg.org/multipage/forms.html#category-reset match child.type_id() { ElementNodeTypeId(HTMLInputElementTypeId) => { let input: JSRef<HTMLInputElement> = HTMLInputElementCast::to_ref(child) .unwrap(); - let ty = input.Type(); - - match ty.as_slice() { - "radio" | "checkbox" => { - // TODO Reset radios/checkboxes here - }, - "image" => (), - _ => () - } - - input.SetValue(input.DefaultValue()); + input.reset() } // TODO HTMLKeygenElement unimplemented - /*ElementNodeTypeID(HTMLKeygenElementTypeId) => { - // Unimplemented - {} - }*/ + //ElementNodeTypeID(HTMLKeygenElementTypeId) => { + // // Unimplemented + // {} + //} ElementNodeTypeId(HTMLSelectElementTypeId) => { // Unimplemented {} @@ -498,4 +483,5 @@ pub trait FormControl<'a> : Copy { fn to_element(self) -> JSRef<'a, Element>; // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-mutable fn mutable(self) -> bool; + fn reset(self); } |