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

Implement basic framework for static and interactive validation on forms #8747

Merged
merged 2 commits into from Dec 17, 2015
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Remove big blob of commented code

  • Loading branch information
KiChjang committed Dec 16, 2015
commit 5ed03a54665eeba06c9a4b372318250f1491ad0e
@@ -270,71 +270,9 @@ impl HTMLFormElement {
if let Some(el) = field.downcast::<Element>() {
None // Remove this line if you decide to refactor

// XXXKiChjang: Refactor the following commented up code so that form control elements
// each have a candidate_for_validation and satisfies_constraints methods

// XXXKiChjang: This should go into candidate_for_validation

// if field.ancestors()
// .any(|a| Root::downcast::<HTMLDataListElement>(a).is_some())
// // XXXKiChjang this may be wrong, this is not checking the ancestor
// // elements to find whether an HTMLFieldSetElement exists and is disabled
// || el.get_disabled_state() {
// return None;
// }


// XXXKiChjang: This should go into satisfies_constraints for each individual form element

// match field.type_id() {
// NodeTypeId::Element(ElementTypeId::HTMLElement(element)) => {
// match element {
// HTMLElementTypeId::HTMLButtonElement => {
// let button = field.downcast::<HTMLButtonElement>().unwrap();
// // Substep 1
// // https://html.spec.whatwg.org/multipage/#the-button-element:barred-from-constraint-validation
// if button.Type() != "submit" { return None; }
// // Substep 2
// // TODO: Check constraints on HTMLButtonElement
// // Substep 3
// Some(FormSubmittableElement::ButtonElement(Root::from_ref(&*button)))
// }
// HTMLElementTypeId::HTMLInputElement => {
// let input = field.downcast::<HTMLInputElement>().unwrap();
// // Substep 1
// // https://html.spec.whatwg.org/multipage/#candidate-for-constraint-validation
// if input.type_() == atom!("hidden")
// || input.type_() == atom!("reset")
// || input.type_() == atom!("button")
// || input.ReadOnly() { return None; }
// // Substep 2
// // TODO: Check constraints on HTMLInputElement
// // Substep 3
// Some(FormSubmittableElement::InputElement(Root::from_ref(&*input)))
// }
// HTMLElementTypeId::HTMLSelectElement => {
// let select = field.downcast::<HTMLSelectElement>().unwrap();
// // Substep 1 not necessary, HTMLSelectElements are not barred from constraint validation
// // Substep 2
// // TODO: Check constraints on HTMLSelectElement
// // Substep 3
// Some(FormSubmittableElement::SelectElement(Root::from_ref(&*select)))
// }
// HTMLElementTypeId::HTMLTextAreaElement => {
// let textarea = field.downcast::<HTMLTextAreaElement>().unwrap();
// // Substep 1
// // https://html.spec.whatwg.org/multipage/#the-textarea-element:barred-from-constraint-validation
// if textarea.ReadOnly() { return None; }
// // Substep 2
// // TODO: Check constraints on HTMLTextAreaElement
// // Substep 3
// Some(FormSubmittableElement::TextAreaElement(Root::from_ref(&*textarea)))
// }
// _ => None
// }
// }
// _ => None
// }
// XXXKiChjang: Form control elements should each have a candidate_for_validation
// and satisfies_constraints methods

} else {
None
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.