Search in sources :

Example 11 with VirtualChildrenList

use of com.vaadin.flow.internal.nodefeature.VirtualChildrenList in project flow by vaadin.

the class PolymerTemplateTest method attachExistingElement_elementIsCreatedAndSetAsVirtualChild.

@Test
public void attachExistingElement_elementIsCreatedAndSetAsVirtualChild() {
    IdElementTemplate template = new IdElementTemplate();
    VirtualChildrenList feature = template.getStateNode().getFeature(VirtualChildrenList.class);
    List<StateNode> templateNodes = new ArrayList<>();
    feature.forEachChild(templateNodes::add);
    assertEquals(1, templateNodes.size());
    StateNode child = templateNodes.get(0);
    String tag = child.getFeature(ElementData.class).getTag();
    assertEquals("label", tag);
    assertNotNull(template.label);
    assertEquals(child, template.label.getNode());
    assertElementData(child, NodeProperties.INJECT_BY_ID, "labelId");
}
Also used : StateNode(com.vaadin.flow.internal.StateNode) ArrayList(java.util.ArrayList) ElementData(com.vaadin.flow.internal.nodefeature.ElementData) VirtualChildrenList(com.vaadin.flow.internal.nodefeature.VirtualChildrenList) Test(org.junit.Test)

Aggregations

VirtualChildrenList (com.vaadin.flow.internal.nodefeature.VirtualChildrenList)11 StateNode (com.vaadin.flow.internal.StateNode)5 ArrayList (java.util.ArrayList)5 ElementData (com.vaadin.flow.internal.nodefeature.ElementData)3 Component (com.vaadin.flow.component.Component)2 Element (com.vaadin.flow.dom.Element)2 Test (org.junit.Test)2 UI (com.vaadin.flow.component.UI)1 JsonArray (elemental.json.JsonArray)1 JsonObject (elemental.json.JsonObject)1