Search in sources :

Example 6 with BindingValueProvider

use of com.vaadin.flow.template.angular.BindingValueProvider in project flow by vaadin.

the class AngularTemplateParserTest method parseTemplateAttribute.

@Test
public void parseTemplateAttribute() {
    ElementTemplateNode rootNode = (ElementTemplateNode) parse("<input [attr.value]='foo'></input>");
    Assert.assertEquals("input", rootNode.getTag());
    Assert.assertEquals(1, rootNode.getAttributeNames().count());
    Assert.assertEquals(0, rootNode.getClassNames().count());
    Assert.assertEquals(0, rootNode.getPropertyNames().count());
    Optional<BindingValueProvider> binding = rootNode.getAttributeBinding("value");
    Assert.assertTrue(binding.isPresent());
    StateNode node = new StateNode(ModelMap.class);
    // Explicitly set "foo" property to null. So model has property "foo".
    // See #970
    ModelMap.get(node).setValue("foo", null);
    Assert.assertNull(binding.get().getValue(node));
    ModelMap.get(node).setValue("foo", "bar");
    Assert.assertEquals("bar", binding.get().getValue(node));
}
Also used : BindingValueProvider(com.vaadin.flow.template.angular.BindingValueProvider) ElementTemplateNode(com.vaadin.flow.template.angular.ElementTemplateNode) StateNode(com.vaadin.flow.internal.StateNode) Test(org.junit.Test)

Aggregations

BindingValueProvider (com.vaadin.flow.template.angular.BindingValueProvider)6 ElementTemplateNode (com.vaadin.flow.template.angular.ElementTemplateNode)6 Test (org.junit.Test)6 StateNode (com.vaadin.flow.internal.StateNode)4 TextTemplateNode (com.vaadin.flow.template.angular.TextTemplateNode)1