use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class PolymerTemplateTest method doParseTemplte_hasChildTemplateOutsideDomRepeat_elementIsCreated.
private void doParseTemplte_hasChildTemplateOutsideDomRepeat_elementIsCreated(TemplateWithDomRepeat template) {
UI ui = new UI();
ui.add(template);
VirtualChildrenList feature = template.getStateNode().getFeature(VirtualChildrenList.class);
List<StateNode> templateNodes = new ArrayList<>();
feature.forEachChild(templateNodes::add);
assertEquals(1, templateNodes.size());
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method testElementJsonProperties.
@Test
public void testElementJsonProperties() {
ElementTemplateBuilder builder = new ElementTemplateBuilder("div").setProperty("a", new ModelValueBindingProvider("key"));
Element element = createElement(builder);
StateNode stateNode = element.getNode();
JsonObject json = Json.createObject();
json.put("foo", "bar");
ModelMap.get(stateNode).setValue("key", json);
Assert.assertEquals(json, element.getPropertyRaw("a"));
Assert.assertEquals(new HashSet<>(Arrays.asList("a")), element.getPropertyNames().collect(Collectors.toSet()));
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method setAttribute_regularAttribute_elementDelegatesAttributeToOverrideNode.
@Test
public void setAttribute_regularAttribute_elementDelegatesAttributeToOverrideNode() {
TemplateNode node = TemplateParser.parse("<div></div>", new NullTemplateResolver());
Element element = createElement(node);
element.setAttribute("attr", "foo");
StateNode overrideNode = element.getNode().getFeature(TemplateOverridesMap.class).get(node, false);
Assert.assertTrue(BasicElementStateProvider.get().hasAttribute(overrideNode, "attr"));
Assert.assertEquals("foo", BasicElementStateProvider.get().getAttribute(overrideNode, "attr"));
List<String> attrs = BasicElementStateProvider.get().getAttributeNames(overrideNode).collect(Collectors.toList());
Assert.assertEquals(1, attrs.size());
Assert.assertEquals("attr", attrs.get(0));
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method testElementDoubleProperties.
@Test
public void testElementDoubleProperties() {
ElementTemplateBuilder builder = new ElementTemplateBuilder("div").setProperty("a", new ModelValueBindingProvider("key"));
Element element = createElement(builder);
StateNode stateNode = element.getNode();
ModelMap.get(stateNode).setValue("key", 1.1d);
Assert.assertEquals(1.1d, element.getPropertyRaw("a"));
Assert.assertEquals(new HashSet<>(Arrays.asList("a")), element.getPropertyNames().collect(Collectors.toSet()));
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method setProperty_regularProperty_elementDelegatesPropertyToOverrideNode.
@Test
public void setProperty_regularProperty_elementDelegatesPropertyToOverrideNode() {
TemplateNode node = TemplateParser.parse("<div></div>", new NullTemplateResolver());
Element element = createElement(node);
element.setProperty("prop", "foo");
StateNode overrideNode = element.getNode().getFeature(TemplateOverridesMap.class).get(node, false);
Assert.assertTrue(BasicElementStateProvider.get().hasProperty(overrideNode, "prop"));
Assert.assertEquals("foo", BasicElementStateProvider.get().getProperty(overrideNode, "prop"));
List<String> props = BasicElementStateProvider.get().getPropertyNames(overrideNode).collect(Collectors.toList());
Assert.assertEquals(1, props.size());
Assert.assertEquals("prop", props.get(0));
}
Aggregations