Skip to content

Commit

Permalink
Merge pull request #81 from davidkarlsson/fix-add-class-error
Browse files Browse the repository at this point in the history
Check if addClass is truthy before adding it to element
  • Loading branch information
haacked authored Nov 2, 2023
2 parents fcb2870 + 2525091 commit 2430929
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ export class ValidationService {
* @param removeClass Class to remove
*/
private swapClasses(element: Element, addClass: string, removeClass: string) {
if (!element.classList.contains(addClass)) {
if (addClass && !element.classList.contains(addClass)) {
element.classList.add(addClass);
}
if (element.classList.contains(removeClass)) {
Expand Down

0 comments on commit 2430929

Please sign in to comment.