Implements DefaultChecked and resets of checkboxes

This commit is contained in:
Matthew Rasmus 2014-12-08 09:19:47 -08:00
parent a5c0bb708d
commit 38e4d86b14
2 changed files with 11 additions and 7 deletions

View file

@ -183,6 +183,12 @@ impl<'a> HTMLInputElementMethods for JSRef<'a, HTMLInputElement> {
// http://www.whatwg.org/html/#dom-fe-disabled
make_bool_setter!(SetDisabled, "disabled")
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-defaultchecked
make_bool_getter!(DefaultChecked, "checked")
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-defaultchecked
make_bool_setter!(SetDefaultChecked, "checked")
// https://html.spec.whatwg.org/multipage/forms.html#dom-input-checked
fn Checked(self) -> bool {
self.checked.get()
@ -573,13 +579,11 @@ impl<'a> FormControl<'a> for JSRef<'a, HTMLInputElement> {
}
fn reset(self) {
let ty = self.Type();
match ty.as_slice() {
"radio" | "checkbox" => {
// TODO Reset radios/checkboxes here
match self.input_type.get() {
InputRadio | InputCheckbox => {
self.SetChecked(self.DefaultChecked());
},
"image" => (),
InputImage => (),
_ => ()
}

View file

@ -9,7 +9,7 @@ interface HTMLInputElement : HTMLElement {
// attribute DOMString alt;
// attribute DOMString autocomplete;
// attribute boolean autofocus;
// attribute boolean defaultChecked;
attribute boolean defaultChecked;
attribute boolean checked;
// attribute DOMString dirName;
attribute boolean disabled;