use of com.vaadin.client.flow.template.TestElementTemplateNode in project flow by vaadin.
the class GwtBasicElementBinderTest method testAddTemplateChild.
public void testAddTemplateChild() {
final int templateId = 43;
TestElementTemplateNode templateNode = TestElementTemplateNode.create("child");
TemplateRegistry templates = new TemplateRegistry();
templates.register(templateId, templateNode);
Registry registry = new Registry() {
{
set(TemplateRegistry.class, templates);
set(ExistingElementMap.class, new ExistingElementMap());
}
};
StateTree stateTree = new StateTree(registry);
StateNode templateStateNode = new StateNode(345, stateTree);
templateStateNode.getMap(NodeFeatures.TEMPLATE).getProperty(NodeProperties.ROOT_TEMPLATE_ID).setValue(Double.valueOf(templateId));
StateNode parentElementNode = new StateNode(94, stateTree);
parentElementNode.getMap(NodeFeatures.ELEMENT_DATA).getProperty(NodeProperties.TAG).setValue("div");
parentElementNode.getList(NodeFeatures.ELEMENT_CHILDREN).add(0, templateStateNode);
Element element = Browser.getDocument().createElement("div");
Binder.bind(parentElementNode, element);
Reactive.flush();
assertEquals(1, element.getChildElementCount());
assertEquals("CHILD", element.getFirstElementChild().getTagName());
}
Aggregations