use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class ElementUtilTest method attachToNull.
@Test(expected = IllegalArgumentException.class)
public void attachToNull() {
Element e = ElementFactory.createDiv();
ElementUtil.setComponent(e, null);
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class ElementUtilTest method attachTwiceToComponent.
@Test(expected = IllegalStateException.class)
public void attachTwiceToComponent() {
Element e = ElementFactory.createDiv();
Component c = Mockito.mock(Component.class);
ElementUtil.setComponent(e, c);
ElementUtil.setComponent(e, c);
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class TemplateElementStateProviderTest method testNestedTemplateElements.
@Test
public void testNestedTemplateElements() {
ElementTemplateBuilder builder = new ElementTemplateBuilder("parent").addChild(new ElementTemplateBuilder("child0")).addChild(new ElementTemplateBuilder("child1"));
Element element = createElement(builder);
Assert.assertEquals(2, element.getChildCount());
Element child0 = element.getChild(0);
Assert.assertEquals("child0", child0.getTag());
Assert.assertEquals(element, child0.getParent());
Element child1 = element.getChild(1);
Assert.assertEquals("child1", child1.getTag());
Assert.assertEquals(element, child1.getParent());
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class TemplateElementStateProviderTest method removeAttribute_templateHasBoundAttribute_hasNoAttributeAndHasBoundAttribute.
@Test
public void removeAttribute_templateHasBoundAttribute_hasNoAttributeAndHasBoundAttribute() {
TemplateNode node = TemplateParser.parse("<div [attr.foo]='bar' attr='foo'></div>", new NullTemplateResolver());
Element element = createElement(node);
element.removeAttribute("attr");
Assert.assertFalse(element.hasAttribute("attr"));
Assert.assertTrue(element.hasAttribute("foo"));
List<String> attrs = element.getAttributeNames().collect(Collectors.toList());
Assert.assertEquals(1, attrs.size());
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class TemplateElementStateProviderTest method setProperty_boundProperty_throwException.
@Test(expected = IllegalArgumentException.class)
public void setProperty_boundProperty_throwException() {
Element element = createElement("<div [prop]='value'></div>");
element.setProperty("prop", "foo");
}
Aggregations