Skip to content

Commit

Permalink
Implements DefaultChecked and resets of checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
mttr committed Dec 16, 2014
1 parent a5c0bb7 commit 38e4d86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions components/script/dom/htmlinputelement.rs
Expand Up @@ -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()
Expand Down Expand Up @@ -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 => (),
_ => ()
}

Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/webidls/HTMLInputElement.webidl
Expand Up @@ -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;
Expand Down

0 comments on commit 38e4d86

Please sign in to comment.