import HTMLElement from '../html-element/HTMLElement';
import IElement from '../element/IElement';
import IHTMLFormElement from './IHTMLFormElement';
/**
* HTML Form Element.
*
* Reference:
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement.
*/
export default class HTMLFormElement extends HTMLElement implements IHTMLFormElement {
/**
* Returns name.
*
* @returns Name.
*/
public get name(): string {
return this.getAttributeNS(null, 'name') || '';
}
/**
* Sets name.
*
* @param name Name.
*/
public set name(name: string) {
this.setAttributeNS(null, 'name', name);
}
/**
* Returns method.
*
* @returns Method.
*/
public get method(): string {
return this.getAttributeNS(null, 'method') || 'get';
}
/**
* Sets method.
*
* @param method Method.
*/
public set method(method: string) {
this.setAttributeNS(null, 'method', method);
}
/**
* Returns target.
*
* @returns Target.
*/
public get target(): string {
return this.getAttributeNS(null, 'target') || '';
}
/**
* Sets target.
*
* @param target Target.
*/
public set target(target: string) {
this.setAttributeNS(null, 'target', target);
}
/**
* Returns action.
*
* @returns Action.
*/
public get action(): string {
return this.getAttributeNS(null, 'action') || '';
}
/**
* Sets action.
*
* @param action Action.
*/
public set action(action: string) {
this.setAttributeNS(null, 'action', action);
}
/**
* Returns encoding.
*
* @returns Encoding.
*/
public get encoding(): string {
return this.getAttributeNS(null, 'encoding') || '';
}
/**
* Sets encoding.
*
* @param encoding Encoding.
*/
public set encoding(encoding: string) {
this.setAttributeNS(null, 'encoding', encoding);
}
/**
* Returns enctype.
*
* @returns Enctype.
*/
public get enctype(): string {
return this.getAttributeNS(null, 'enctype') || '';
}
/**
* Sets enctype.
*
* @param enctype Enctype.
*/
public set enctype(enctype: string) {
this.setAttributeNS(null, 'enctype', enctype);
}
/**
* Returns autocomplete.
*
* @returns Autocomplete.
*/
public get autocomplete(): string {
return this.getAttributeNS(null, 'autocomplete') || '';
}
/**
* Sets autocomplete.
*
* @param autocomplete Autocomplete.
*/
public set autocomplete(autocomplete: string) {
this.setAttributeNS(null, 'autocomplete', autocomplete);
}
/**
* Returns accept charset.
*
* @returns Accept charset.
*/
public get acceptCharset(): string {
return this.getAttributeNS(null, 'acceptcharset') || '';
}
/**
* Sets accept charset.
*
* @param acceptCharset Accept charset.
*/
public set acceptCharset(acceptCharset: string) {
this.setAttributeNS(null, 'acceptcharset', acceptCharset);
}
/**
* Returns no validate.
*
* @returns No validate.
*/
public get noValidate(): string {
return this.getAttributeNS(null, 'novalidate') || '';
}
/**
* Sets no validate.
*
* @param noValidate No validate.
*/
public set noValidate(noValidate: string) {
this.setAttributeNS(null, 'novalidate', noValidate);
}
/**
* Returns input elements.
*
* @returns Elements.
*/
public get elements(): IElement[] {
return this.querySelectorAll('input,textarea');
}
/**
* Returns number of input elements.
*
* @returns Length.
*/
public get length(): number {
return this.elements.length;
}
/**
* Submits form.
*/
public submit(): void {}
/**
* Resets form.
*/
public reset(): void {}
/**
* Reports validity.
*/
public reportValidity(): void {}
/**
* Checks validity.
*
* @returns "true" if validation does'nt fail.
*/
public checkValidity(): boolean {
return true;
}
/**
* Clones a node.
*
* @override
* @param [deep=false] "true" to clone deep.
* @returns Cloned node.
*/
public cloneNode(deep = false): IHTMLFormElement {
return super.cloneNode(deep);
}
}