Implement support for modifying the type attribute of button elements. Fixes #9091.

This commit is contained in:
Josh Matthews 2015-12-30 16:04:05 -05:00
parent d6d70feabd
commit ffc1c777fe
2 changed files with 17 additions and 9 deletions

View file

@ -27,7 +27,6 @@ use string_cache::Atom;
use util::str::DOMString; use util::str::DOMString;
#[derive(JSTraceable, PartialEq, Copy, Clone)] #[derive(JSTraceable, PartialEq, Copy, Clone)]
#[allow(dead_code)]
#[derive(HeapSizeOf)] #[derive(HeapSizeOf)]
enum ButtonType { enum ButtonType {
Submit, Submit,
@ -50,7 +49,6 @@ impl HTMLButtonElement {
htmlelement: htmlelement:
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE, HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,
localName, prefix, document), localName, prefix, document),
//TODO: implement button_type in attribute_mutated
button_type: Cell::new(ButtonType::Submit) button_type: Cell::new(ButtonType::Submit)
} }
} }
@ -162,6 +160,22 @@ impl VirtualMethods for HTMLButtonElement {
} }
} }
}, },
&atom!("type") => {
match mutation {
AttributeMutation::Set(_) => {
let value = match &**attr.value() {
"reset" => ButtonType::Reset,
"button" => ButtonType::Button,
"menu" => ButtonType::Menu,
_ => ButtonType::Submit,
};
self.button_type.set(value);
}
AttributeMutation::Removed => {
self.button_type.set(ButtonType::Submit);
}
}
}
_ => {}, _ => {},
} }
} }

View file

@ -1,12 +1,6 @@
[button-events.html] [button-events.html]
type: testharness type: testharness
expected: CRASH expected: TIMEOUT
[The submit event must be fired when click a button in submit status]
expected: TIMEOUT
[The reset event must be fired when click a button in reset status]
expected: TIMEOUT
[The show event must be fired when click a button in menu status] [The show event must be fired when click a button in menu status]
expected: TIMEOUT expected: TIMEOUT