Skip to content

Commit

Permalink
Don't bother adding a class if it's already set
Browse files Browse the repository at this point in the history
  • Loading branch information
campbell-m committed Oct 27, 2024
1 parent b2f6591 commit 3cdb1c9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions web/lib/MRBS/Form/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,11 @@ public function addClass(string $class) : Element
$classes = $this->getAttribute('class');

$classes = (isset($classes)) ? explode(' ', $classes) : array();
$classes[] = $class;
$this->setAttribute('class', implode(' ', $classes));
if (!in_array($class, $classes))
{
$classes[] = $class;
$this->setAttribute('class', implode(' ', $classes));
}

return $this;
}
Expand Down

0 comments on commit 3cdb1c9

Please sign in to comment.