Skip to content

Commit

Permalink
Fix setClassName to work as specified in javadoc (#8842)
Browse files Browse the repository at this point in the history
Fixes #8840
  • Loading branch information
caalador authored Aug 12, 2020
1 parent 80e3194 commit 0e94214
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ default boolean removeClassName(String className) {
* <code>null</code> to remove all class names
*/
default void setClassName(String className) {
getElement().setAttribute("class", className);
if(className == null) {
getElement().removeAttribute("class");
} else {
getElement().setAttribute("class", className);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public void setClassName() {
assertClasses(component);
component.setClassName("");
assertClasses(component);

component.setClassName("removeMe");
// setting null to classname should remove class name attribute
component.setClassName(null);
assertClasses(component);
}

@Test
Expand Down

0 comments on commit 0e94214

Please sign in to comment.