use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class SimpleElementBindingStrategy method listenToSubPropertiesChanges.
private void listenToSubPropertiesChanges(Element htmlNode, String polymerModelPath, int subNodeIndex, Object item) {
if (item instanceof StateNode) {
StateNode stateNode = (StateNode) item;
NodeMap feature = null;
if (stateNode.hasFeature(NodeFeatures.ELEMENT_PROPERTIES)) {
feature = stateNode.getMap(NodeFeatures.ELEMENT_PROPERTIES);
} else if (stateNode.hasFeature(NodeFeatures.BASIC_TYPE_VALUE)) {
feature = stateNode.getMap(NodeFeatures.BASIC_TYPE_VALUE);
}
if (feature != null) {
feature.addPropertyAddListener(event -> {
Command command = () -> PolymerUtils.setListValueByIndex(htmlNode, polymerModelPath, subNodeIndex, PolymerUtils.convertToJson(event.getProperty()));
invokeWhenNodeIsConstructed(command, stateNode);
});
}
}
}
use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class GwtTemplateBinderTest method testAttributeBindingTemplate.
public void testAttributeBindingTemplate() {
TestElementTemplateNode templateNode = TestElementTemplateNode.create("div");
templateNode.addAttribute("attr", TestBinding.createBinding(ModelValueBindingProvider.TYPE, MODEL_KEY));
NodeMap map = stateNode.getMap(NodeFeatures.TEMPLATE_MODELMAP);
map.getProperty(MODEL_KEY).setValue("foo");
Element domNode = createElement(templateNode);
Reactive.flush();
assertEquals("foo", domNode.getAttribute("attr"));
}
use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class GwtTemplateBinderTest method testUpdateAttributeBindingTemplate.
public void testUpdateAttributeBindingTemplate() {
TestElementTemplateNode templateNode = TestElementTemplateNode.create("div");
templateNode.addAttribute("attr", TestBinding.createBinding(ModelValueBindingProvider.TYPE, MODEL_KEY));
NodeMap map = stateNode.getMap(NodeFeatures.TEMPLATE_MODELMAP);
map.getProperty(MODEL_KEY).setValue("foo");
Element domNode = createElement(templateNode);
Reactive.flush();
map.getProperty(MODEL_KEY).setValue("bar");
Reactive.flush();
assertEquals("bar", domNode.getAttribute("attr"));
}
use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class GwtTemplateBinderTest method testJSExpressionInBinding.
public void testJSExpressionInBinding() {
// create binding with expression : : key ? key+'@bar.com' :'foo'
TestTextTemplate templateNode = TestTextTemplate.create(TestBinding.createTextValueBinding(MODEL_KEY + " ? " + MODEL_KEY + "+'@bar.com' : 'foo'"));
Node domNode = createText(templateNode);
NodeMap map = stateNode.getMap(NodeFeatures.TEMPLATE_MODELMAP);
map.getProperty(MODEL_KEY).setValue(null);
Reactive.flush();
assertEquals("foo", domNode.getTextContent());
map.getProperty(MODEL_KEY).setValue("value");
Reactive.flush();
assertEquals("value@bar.com", domNode.getTextContent());
}
use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class GwtTemplateBinderTest method testPropertyBindingNoValueTemplate.
public void testPropertyBindingNoValueTemplate() {
TestElementTemplateNode templateNode = TestElementTemplateNode.create("div");
templateNode.addProperty("prop", TestBinding.createBinding(ModelValueBindingProvider.TYPE, MODEL_KEY));
Node domNode = createElement(templateNode);
NodeMap map = stateNode.getMap(NodeFeatures.TEMPLATE_MODELMAP);
map.getProperty(MODEL_KEY).setValue(null);
Reactive.flush();
assertEquals(null, WidgetUtil.getJsProperty(domNode, "prop"));
}
Aggregations