Skip to content

HasStyle.addClassNames() doesn't handle multiple whitespaces #11709

@mvysny

Description

@mvysny

Description of the bug / feature

new Div().addClassNames("   foo  bar    baz")

fails with

java.lang.IllegalArgumentException: Class name cannot be empty
	at com.vaadin.flow.internal.nodefeature.ElementClassList$ClassListView.validate(ElementClassList.java:45)
	at com.vaadin.flow.internal.nodefeature.ElementClassList$ClassListView.validate(ElementClassList.java:31)
	at com.vaadin.flow.internal.nodefeature.NodeList$SetView.add(NodeList.java:113)
	at com.vaadin.flow.internal.nodefeature.NodeList$SetView.add(NodeList.java:86)
	at com.vaadin.flow.component.HasStyle.addClassNames(HasStyle.java:144)

Expected behavior

The div should have three class names added.

Actual behavior

The code fails with an exception

Versions:

- Vaadin / Flow version: 14.6.8
- Java version: 8

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions