use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class InertData method updateInertAndCascadeToChildren.
private void updateInertAndCascadeToChildren(Boolean resolvedParentInert) {
boolean newInert = resolveInert(resolvedParentInert);
if (cachedInert != null && cachedInert == newInert) {
return;
}
// cascade update to all children unless those are ignoring parent
// value or have same value and thus don't need updating.
// (all explicitly updated nodes are visited separately)
Deque<StateNode> stack = new ArrayDeque<>();
getNode().forEachChild(stack::add);
while (!stack.isEmpty()) {
StateNode node = stack.pop();
if (node.hasFeature(InertData.class)) {
final Optional<InertData> featureIfInitialized = node.getFeatureIfInitialized(InertData.class);
if (featureIfInitialized.isPresent()) {
featureIfInitialized.get().updateInertAndCascadeToChildren(newInert);
} else {
node.forEachChild(stack::push);
}
} else {
node.forEachChild(stack::push);
}
}
cachedInert = newInert;
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class PolymerTemplateTest method doParseTemplate_hasChildTemplateOutsideDomRepeat_elementIsCreated.
private void doParseTemplate_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 PolymerTemplateTest method attachExistingElement_injectedByIDdChild_onlyOneElementIsCreated.
@Test
public void attachExistingElement_injectedByIDdChild_onlyOneElementIsCreated() {
TemplateInjectTemplate template = new TemplateInjectTemplate();
VirtualChildrenList feature = template.getStateNode().getFeature(VirtualChildrenList.class);
List<StateNode> templateNodes = new ArrayList<>();
feature.forEachChild(templateNodes::add);
assertEquals(1, templateNodes.size());
StateNode stateNode = templateNodes.get(0);
assertEquals(stateNode, template.child.getStateNode());
assertElementData(stateNode, NodeProperties.INJECT_BY_ID, "child");
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class PolymerTemplateTest method attachComponentAndVerifyChild.
private void attachComponentAndVerifyChild(PolymerTemplate<?> template, CustomComponent templateChild) {
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("div", tag);
assertNotNull(templateChild);
assertEquals(child, templateChild.getElement().getNode());
assertTrue(templateChild.getElement().getComponent().isPresent());
assertTrue(templateChild.getElement().getComponent().get() instanceof CustomComponent);
assertEquals(templateChild, templateChild.getElement().getComponent().get());
assertElementData(child, NodeProperties.INJECT_BY_ID, "child");
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class PolymerTemplateTest method doParseTemplate_hasChildTemplate_elementIsCreatedAndSetAsVirtualChild.
private void doParseTemplate_hasChildTemplate_elementIsCreatedAndSetAsVirtualChild(PolymerTemplate<?> template) {
VirtualChildrenList feature = template.getStateNode().getFeature(VirtualChildrenList.class);
List<StateNode> templateNodes = new ArrayList<>();
feature.forEachChild(templateNodes::add);
assertEquals(2, templateNodes.size());
StateNode child1 = templateNodes.get(0);
StateNode child2 = templateNodes.get(1);
String tag = child1.getFeature(ElementData.class).getTag();
if ("child-template".equals(tag)) {
assertEquals("ffs", child2.getFeature(ElementData.class).getTag());
} else {
assertEquals("ffs", child1.getFeature(ElementData.class).getTag());
assertEquals("child-template", child2.getFeature(ElementData.class).getTag());
}
assertTemplateInTempalte(child1);
assertTemplateInTempalte(child2);
}
Aggregations