use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class TemplateElementStateProviderTest method testRemoveByIndexWithTemplateChildren.
@Test(expected = IllegalStateException.class)
public void testRemoveByIndexWithTemplateChildren() {
Element parent = createElement("<div><span></span></div>");
parent.removeChild(0);
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class TemplateElementStateProviderTest method templateStaticStyleHasUsingDashSeparated.
@Test
public void templateStaticStyleHasUsingDashSeparated() {
Element element = createElement("<div style='font-size:14px'></div>");
Assert.assertTrue(element.getStyle().has("font-size"));
Assert.assertTrue(element.getStyle().has("fontSize"));
Assert.assertFalse(element.getStyle().has("fontsize"));
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class TemplateElementStateProviderTest method setAttribute_regularAttribute_elementDelegatesAttributeToOverrideNode.
@Test
public void setAttribute_regularAttribute_elementDelegatesAttributeToOverrideNode() {
TemplateNode node = TemplateParser.parse("<div></div>", new NullTemplateResolver());
Element element = createElement(node);
element.setAttribute("attr", "foo");
StateNode overrideNode = element.getNode().getFeature(TemplateOverridesMap.class).get(node, false);
Assert.assertTrue(BasicElementStateProvider.get().hasAttribute(overrideNode, "attr"));
Assert.assertEquals("foo", BasicElementStateProvider.get().getAttribute(overrideNode, "attr"));
List<String> attrs = BasicElementStateProvider.get().getAttributeNames(overrideNode).collect(Collectors.toList());
Assert.assertEquals(1, attrs.size());
Assert.assertEquals("attr", attrs.get(0));
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class TemplateElementStateProviderTest method removeAttribute_regularAttribute_hasNoAttribute.
@Test
public void removeAttribute_regularAttribute_hasNoAttribute() {
TemplateNode node = TemplateParser.parse("<div></div>", new NullTemplateResolver());
Element element = createElement(node);
element.setAttribute("attr", "foo");
element.removeAttribute("attr");
Assert.assertFalse(element.hasAttribute("attr"));
List<String> props = element.getAttributeNames().collect(Collectors.toList());
Assert.assertEquals(0, props.size());
}
use of com.vaadin.flow.dom.Element in project flow by vaadin.
the class TemplateElementStateProviderTest method testElementDoubleProperties.
@Test
public void testElementDoubleProperties() {
ElementTemplateBuilder builder = new ElementTemplateBuilder("div").setProperty("a", new ModelValueBindingProvider("key"));
Element element = createElement(builder);
StateNode stateNode = element.getNode();
ModelMap.get(stateNode).setValue("key", 1.1d);
Assert.assertEquals(1.1d, element.getPropertyRaw("a"));
Assert.assertEquals(new HashSet<>(Arrays.asList("a")), element.getPropertyNames().collect(Collectors.toSet()));
}
Aggregations