use of com.vaadin.flow.template.angular.ElementTemplateBuilder in project flow by vaadin.
the class TemplateElementStateProviderTest method testElementAttributes.
@Test
public void testElementAttributes() {
ElementTemplateBuilder builder = new ElementTemplateBuilder("div").setAttribute("a1", new StaticBindingValueProvider("v1")).setAttribute("a2", new StaticBindingValueProvider("v2"));
Element element = createElement(builder);
Assert.assertEquals("v1", element.getAttribute("a1"));
Assert.assertEquals("v2", element.getAttribute("a2"));
Assert.assertEquals(new HashSet<>(Arrays.asList("a1", "a2")), element.getAttributeNames().collect(Collectors.toSet()));
}
use of com.vaadin.flow.template.angular.ElementTemplateBuilder in project flow by vaadin.
the class DefaultElementBuilderFactory method createBuilder.
@Override
public TemplateNodeBuilder createBuilder(Element element, Function<Node, Optional<TemplateNodeBuilder>> builderProducer) {
ElementTemplateBuilder builder = new ElementTemplateBuilder(element.tagName());
element.attributes().forEach(attr -> setBinding(attr, builder, element));
element.childNodes().stream().map(builderProducer::apply).filter(Optional::isPresent).map(Optional::get).forEach(builder::addChild);
return builder;
}
Aggregations