Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
checkValidity: () => {
const classList = this.root.ref && this.root.ref.classList;
if (
classList &&
classList.contains(MDCSelectFoundation.cssClasses.REQUIRED) &&
!classList.contains(MDCSelectFoundation.cssClasses.DISABLED)
) {
// See notes for required attribute under https://www.w3.org/TR/html52/sec-forms.html#the-select-element
// TL;DR: Invalid if no index is selected, or if the first index is selected and has an empty value.
return (
this.state.selectedIndex !== -1 &&
(this.state.selectedIndex !== 0 || !!this.value)
);
} else {
return true;
}
},
setValid: (isValid: boolean) => {
checkValidity: () => {
const classList = this.root.ref && this.root.ref.classList;
if (
classList &&
classList.contains(MDCSelectFoundation.cssClasses.REQUIRED) &&
!classList.contains(MDCSelectFoundation.cssClasses.DISABLED)
) {
// See notes for required attribute under https://www.w3.org/TR/html52/sec-forms.html#the-select-element
// TL;DR: Invalid if no index is selected, or if the first index is selected and has an empty value.
return (
this.state.selectedIndex !== -1 &&
(this.state.selectedIndex !== 0 || !!this.value)
);
} else {
return true;
}
},
setValid: (isValid: boolean) => {