Search in sources :

Example 1 with SimpleElementBindingStrategy

use of com.vaadin.client.flow.binding.SimpleElementBindingStrategy in project flow by vaadin.

the class GwtTemplateBinderTest method testRemoveTemplateFromDom.

public void testRemoveTemplateFromDom() {
    int templateNodeId = 1;
    TestElementTemplateNode templateNode = TestElementTemplateNode.create("span");
    StateNode templateState = new StateNode(1, stateNode.getTree());
    registerTemplateNode(templateNode, templateState, templateNodeId);
    StateNode simpleNode = new StateNode(2, tree);
    simpleNode.getMap(NodeFeatures.ELEMENT_DATA).getProperty(NodeProperties.TAG).setValue("div");
    simpleNode.getList(NodeFeatures.ELEMENT_CHILDREN).add(0, templateState);
    Element element = new SimpleElementBindingStrategy().create(simpleNode);
    Binder.bind(simpleNode, element);
    Reactive.flush();
    assertEquals(1, element.getChildElementCount());
    assertEquals("SPAN", element.getFirstElementChild().getTagName());
    simpleNode.getList(NodeFeatures.ELEMENT_CHILDREN).splice(0, 1);
    Reactive.flush();
    assertEquals(0, element.getChildElementCount());
}
Also used : SimpleElementBindingStrategy(com.vaadin.client.flow.binding.SimpleElementBindingStrategy) Element(elemental.dom.Element) StateNode(com.vaadin.client.flow.StateNode)

Aggregations

StateNode (com.vaadin.client.flow.StateNode)1 SimpleElementBindingStrategy (com.vaadin.client.flow.binding.SimpleElementBindingStrategy)1 Element (elemental.dom.Element)1