import validateEventHandler from './validateEventHandler';
import { Validator } from '../index';
import { Node } from '../../interfaces';
export default function validateElement ( validator: Validator, node: Node ) {
const isComponent = node.name === ':Self' || validator.components.has( node.name );
let hasIntro: boolean;
let hasOutro: boolean;
let hasTransition: boolean;
node.attributes.forEach( ( attribute: Node ) => {
if ( !isComponent && attribute.type === 'Binding' ) {
const { name } = attribute;
if ( name === 'value' ) {
if ( node.name !== 'input' && node.name !== 'textarea' && node.name !== 'select' ) {
validator.error( `'value' is not a valid binding on <${node.name}> elements`, attribute.start );
}
}
else if ( name === 'checked' ) {
if ( node.name !== 'input' ) {
validator.error( `'checked' is not a valid binding on <${node.name}> elements`, attribute.start );
}
if ( getType( validator, node ) !== 'checkbox' ) {
validator.error( `'checked' binding can only be used with `, attribute.start );
}
}
else if ( name === 'group' ) {
if ( node.name !== 'input' ) {
validator.error( `'group' is not a valid binding on <${node.name}> elements`, attribute.start );
}
const type = getType( validator, node );
if ( type !== 'checkbox' && type !== 'radio' ) {
validator.error( `'checked' binding can only be used with or `, attribute.start );
}
}
else if ( name === 'currentTime' || name === 'duration' || name === 'paused' ) {
if ( node.name !== 'audio' && node.name !== 'video' ) {
validator.error( `'${name}' binding can only be used with