use of com.vaadin.flow.dom.ClassList in project flow by vaadin.
the class ElementTest method testContainsClassWithSpaces.
@Test
public void testContainsClassWithSpaces() {
ClassList cl = ElementFactory.createDiv().getClassList();
cl.add("foo");
cl.add("bar");
Assert.assertFalse(cl.contains("foo bar"));
}
use of com.vaadin.flow.dom.ClassList in project flow by vaadin.
the class ElementTest method testRemoveClassWithSpaces.
@Test
public void testRemoveClassWithSpaces() {
ClassList cl = ElementFactory.createDiv().getClassList();
cl.add("foo");
cl.add("bar");
cl.remove("foo bar");
Assert.assertEquals(2, cl.size());
}
use of com.vaadin.flow.dom.ClassList in project flow by vaadin.
the class TemplateElementStateProviderTest method dynamicClassNames.
@Test
public void dynamicClassNames() {
Element element = createElement("<div class='foo' [class.bar]=hasBar [class.baz]=hasBaz></div>");
ClassList classList = element.getClassList();
// Explicitly set "hasBar" and "hasBaz" properties to null. So model has
// properties "hasBar" and "hasBaz".
// See #970
element.getNode().getFeature(ModelMap.class).setValue("hasBar", null);
element.getNode().getFeature(ModelMap.class).setValue("hasBaz", null);
Assert.assertEquals("foo", element.getAttribute("class"));
assertClassList(classList, "foo");
assertNotClassList(classList, "bar", "baz");
ModelMap modelMap = element.getNode().getFeature(ModelMap.class);
modelMap.setValue("hasBar", "");
modelMap.setValue("hasBaz", "yes");
assertClassList(classList, "foo", "baz");
assertNotClassList(classList, "bar");
modelMap.setValue("hasBar", 5);
modelMap.setValue("hasBaz", 0);
assertClassList(classList, "foo", "bar");
assertNotClassList(classList, "baz");
modelMap.setValue("hasBar", false);
modelMap.setValue("hasBaz", true);
assertClassList(classList, "foo", "baz");
assertNotClassList(classList, "bar");
}