Search in sources :

Example 31 with TemplateNode

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

the class ScriptParsingTest method scriptWithAttributes.

@Test
public void scriptWithAttributes() {
    TemplateNode templateNode = parse("<script type='text/javascript' src='file://foobar'/>");
    Assert.assertEquals(ElementTemplateNode.class, templateNode.getClass());
    ElementTemplateNode elementTemplate = (ElementTemplateNode) templateNode;
    Assert.assertEquals("script", elementTemplate.getTag());
    Assert.assertEquals("text/javascript", elementTemplate.getAttributeBinding("type").get().getValue(new StateNode()));
    Assert.assertEquals("file://foobar", elementTemplate.getAttributeBinding("src").get().getValue(new StateNode()));
}
Also used : TextTemplateNode(com.vaadin.flow.template.angular.TextTemplateNode) ElementTemplateNode(com.vaadin.flow.template.angular.ElementTemplateNode) TemplateNode(com.vaadin.flow.template.angular.TemplateNode) ElementTemplateNode(com.vaadin.flow.template.angular.ElementTemplateNode) StateNode(com.vaadin.flow.internal.StateNode) Test(org.junit.Test)

Example 32 with TemplateNode

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

the class ScriptParsingTest method emptyInlineStyle.

@Test
public void emptyInlineStyle() {
    TemplateNode templateNode = parse("<style></style>");
    Assert.assertEquals(ElementTemplateNode.class, templateNode.getClass());
    ElementTemplateNode elementTemplate = (ElementTemplateNode) templateNode;
    Assert.assertEquals("style", elementTemplate.getTag());
    Assert.assertEquals(0, elementTemplate.getChildCount());
}
Also used : TextTemplateNode(com.vaadin.flow.template.angular.TextTemplateNode) ElementTemplateNode(com.vaadin.flow.template.angular.ElementTemplateNode) TemplateNode(com.vaadin.flow.template.angular.TemplateNode) ElementTemplateNode(com.vaadin.flow.template.angular.ElementTemplateNode) Test(org.junit.Test)

Example 33 with TemplateNode

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

the class AngularTemplateNodeTest method unknownElementLookup.

@Test
public void unknownElementLookup() {
    TemplateNode templateNode = parse("<div><div>");
    Assert.assertEquals(Optional.empty(), templateNode.findElement(TemplateElementStateProvider.createRootNode(), "foo"));
}
Also used : TemplateNode(com.vaadin.flow.template.angular.TemplateNode) Test(org.junit.Test) TemplateElementStateProviderTest(com.vaadin.flow.dom.TemplateElementStateProviderTest)

Example 34 with TemplateNode

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

the class AngularTemplateParserTest method tempalteNodesReused.

@Test
public void tempalteNodesReused() {
    String templateString = "<div></div>";
    TemplateNode a = TemplateParser.parse(templateString, null);
    TemplateNode b = TemplateParser.parse(new ByteArrayInputStream(templateString.getBytes(StandardCharsets.UTF_8)), null);
    Assert.assertSame(a, b);
}
Also used : TextTemplateNode(com.vaadin.flow.template.angular.TextTemplateNode) ElementTemplateNode(com.vaadin.flow.template.angular.ElementTemplateNode) ForTemplateNode(com.vaadin.flow.template.angular.ForTemplateNode) TemplateNode(com.vaadin.flow.template.angular.TemplateNode) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.Test)

Example 35 with TemplateNode

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

the class ForElementTemplateNodeTest method oneChildWithPropertyBinding.

@Test
public void oneChildWithPropertyBinding() {
    TemplateNode divTemplateNode = parse("<div><li *ngFor='let item of items' [value]='item.value'></div>");
    TemplateNode templateNode = divTemplateNode.getChild(0);
    Element div = getElement(divTemplateNode);
    Map<String, String> data = new HashMap<>();
    data.put("value", "propertyValue");
    StateNode model = createModel(div, "items", data);
    Assert.assertEquals(1, templateNode.getGeneratedElementCount(model));
    Assert.assertEquals("propertyValue", templateNode.getElement(0, model).getProperty("value"));
}
Also used : TemplateNode(com.vaadin.flow.template.angular.TemplateNode) HashMap(java.util.HashMap) Element(com.vaadin.flow.dom.Element) StateNode(com.vaadin.flow.internal.StateNode) Test(org.junit.Test) TemplateElementStateProviderTest(com.vaadin.flow.dom.TemplateElementStateProviderTest)

Aggregations

TemplateNode (com.vaadin.flow.template.angular.TemplateNode)48 Test (org.junit.Test)42 Element (com.vaadin.flow.dom.Element)29 StateNode (com.vaadin.flow.internal.StateNode)18 ElementTemplateNode (com.vaadin.flow.template.angular.ElementTemplateNode)13 TemplateElementStateProviderTest (com.vaadin.flow.dom.TemplateElementStateProviderTest)12 TextTemplateNode (com.vaadin.flow.template.angular.TextTemplateNode)11 TemplateOverridesMap (com.vaadin.flow.internal.nodefeature.TemplateOverridesMap)4 HashMap (java.util.HashMap)4 ForTemplateNode (com.vaadin.flow.template.angular.ForTemplateNode)3 TemplateMap (com.vaadin.flow.internal.nodefeature.TemplateMap)2 Component (com.vaadin.flow.component.Component)1 UIInternals (com.vaadin.flow.component.internal.UIInternals)1 StateTree (com.vaadin.flow.internal.StateTree)1 MapPutChange (com.vaadin.flow.internal.change.MapPutChange)1 ModelList (com.vaadin.flow.internal.nodefeature.ModelList)1 ModelMap (com.vaadin.flow.internal.nodefeature.ModelMap)1 ChildSlotNode (com.vaadin.flow.template.angular.ChildSlotNode)1 ElementTemplateBuilder (com.vaadin.flow.template.angular.ElementTemplateBuilder)1 StaticBindingValueProvider (com.vaadin.flow.template.angular.StaticBindingValueProvider)1