Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements basic form resetting #4133

Merged
merged 12 commits into from Dec 16, 2014

Implements reset button

  • Loading branch information
mttr committed Dec 16, 2014
commit 4d0a6a6bd6f2aed259988969fab1f14c880c2257
@@ -27,7 +27,7 @@ use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlelement::HTMLElement;
use dom::keyboardevent::KeyboardEvent;
use dom::htmlformelement::{InputElement, FormControl, HTMLFormElement, HTMLFormElementHelpers};
use dom::htmlformelement::{NotFromFormSubmitMethod};
use dom::htmlformelement::{NotFromFormSubmitMethod, NotFromFormResetMethod};
use dom::node::{DisabledStateHelpers, Node, NodeHelpers, ElementNodeTypeId, OtherNodeDamage};
use dom::node::{document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
@@ -701,6 +701,15 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
});
}
},
InputReset => {
// https://html.spec.whatwg.org/multipage/forms.html#reset-button-state-(type=reset):activation-behavior
// FIXME (Manishearth): support document owners (needs ability to get parent browsing context)
if self.mutable() /* and document owner is fully active */ {
self.form_owner().map(|o| {
o.root().reset(NotFromFormResetMethod)
});
}
},
InputCheckbox | InputRadio => {
// https://html.spec.whatwg.org/multipage/forms.html#checkbox-state-(type=checkbox):activation-behavior
// https://html.spec.whatwg.org/multipage/forms.html#radio-button-state-(type=radio):activation-behavior
@@ -0,0 +1,17 @@
<html>
<head></head>
<body>
<!-- Run with nc -l 8000 -->
<form action="http://localhost:8000" method=get id="foo">
<input name=bar type=checkbox checked>
<input name=baz value="baz1" type=radio checked>
<input name=baz value="baz2" type=radio>
<input type=text id=hi name=bye value="hi!">
<input type=text id=aloha name=empty value="">
<input type=text id=welcome name=reallyempty>
<textarea id=textarea>Hello
TextArea!</textarea>
<input type=reset>
</form>
</body>
</html>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.