use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class ElementUtilTest method setupElementHierarchy.
private void setupElementHierarchy() {
parent = ElementFactory.createDiv();
child = ElementFactory.createDiv();
grandchild = ElementFactory.createDiv();
parent.appendChild(child.appendChild(grandchild));
stateTree = new StateTree(new UI().getInternals(), ElementChildrenList.class, InertData.class);
final StateNode rootNode = stateTree.getRootNode();
rootNode.getFeature(ElementChildrenList.class).add(0, parent.getNode());
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class ElementTest method getElementFromInvalidNode.
@Test(expected = IllegalArgumentException.class)
public void getElementFromInvalidNode() {
StateNode node = new StateNode(ElementPropertyMap.class);
Element.get(node);
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class ShadowRootStateProviderTest method createShadowRootNode_originalNodeIsInitialized.
@Test
public void createShadowRootNode_originalNodeIsInitialized() {
ShadowRootStateProvider provider = ShadowRootStateProvider.get();
StateNode node = new StateNode(ShadowRootData.class);
StateNode shadowRoot = provider.createShadowRootNode(node);
Assert.assertEquals(shadowRoot, node.getFeature(ShadowRootData.class).getShadowRoot());
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class PolymerTemplate method removeSimpleProperties.
private List<String> removeSimpleProperties() {
ElementPropertyMap map = getStateNode().getFeature(ElementPropertyMap.class);
List<String> props = map.getPropertyNames().filter(name -> !(map.getProperty(name) instanceof StateNode)).collect(Collectors.toList());
props.forEach(map::removeProperty);
return props;
}
use of com.vaadin.flow.internal.StateNode in project flow by vaadin.
the class TemplateElementStateProvider method getChild.
@Override
public Element getChild(StateNode node, int index) {
int templateChildCount = templateNode.getChildCount();
if (templateChildCount == 0) {
// No children according to the template, could still have an
// override node with children
Optional<StateNode> overrideNode = getOverrideNode(node);
if (overrideNode.isPresent()) {
return BasicElementStateProvider.get().getChild(overrideNode.get(), index);
}
}
int currentChildIndex = 0;
for (int i = 0; i < templateChildCount; i++) {
TemplateNode templateChild = templateNode.getChild(i);
int generateCount = templateChild.getGeneratedElementCount(node);
int indexInChild = index - currentChildIndex;
if (indexInChild < generateCount) {
return templateChild.getElement(indexInChild, node);
}
currentChildIndex += generateCount;
}
throw new IndexOutOfBoundsException();
}
Aggregations