Implement initial pieces of form validation.

This commit is contained in:
Sagar Muchhal 2016-03-18 19:53:34 -04:00 committed by Josh Matthews
parent 7a9dc57761
commit 051ffba0e5
14 changed files with 185 additions and 55 deletions

View file

@ -18,6 +18,7 @@ use dom::htmlformelement::{FormControl, FormSubmitter, ResetFrom};
use dom::htmlformelement::{SubmittedFrom, HTMLFormElement};
use dom::node::{Node, UnbindContext, document_from_node, window_from_node};
use dom::nodelist::NodeList;
use dom::validation::Validatable;
use dom::validitystate::ValidityState;
use dom::virtualmethods::VirtualMethods;
use std::ascii::AsciiExt;
@ -66,7 +67,7 @@ impl HTMLButtonElementMethods for HTMLButtonElement {
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
fn Validity(&self) -> Root<ValidityState> {
let window = window_from_node(self);
ValidityState::new(window.r())
ValidityState::new(window.r(), self.upcast())
}
// https://html.spec.whatwg.org/multipage/#dom-fe-disabled
@ -203,6 +204,8 @@ impl VirtualMethods for HTMLButtonElement {
impl FormControl for HTMLButtonElement {}
impl Validatable for HTMLButtonElement {}
impl Activatable for HTMLButtonElement {
fn as_element(&self) -> &Element {
self.upcast()