use of com.vaadin.flow.dom.Node in project flow by vaadin.
the class AbstractNodeStateProvider method attachExistingElement.
@Override
public void attachExistingElement(StateNode node, String tagName, Element previousSibling, ChildElementConsumer callback) {
if (tagName == null) {
throw new IllegalArgumentException("Tag name parameter cannot be null");
}
if (callback == null) {
throw new IllegalArgumentException("Callback parameter cannot be null");
}
/*
* create a node that should represent the client-side element. This
* node won't be available anywhere and will be removed if there is no
* appropriate element on the client-side. This node will be used after
* client-side roundtrip for the appropriate element.
*/
StateNode proposedNode = BasicElementStateProvider.createStateNode(tagName);
node.runWhenAttached(ui -> ui.getInternals().getStateTree().beforeClientResponse(node, context -> {
node.getFeature(AttachExistingElementFeature.class).register(getNode(node), previousSibling, proposedNode, callback);
ui.getPage().executeJs("this.attachExistingElement($0, $1, $2, $3);", getNode(node), previousSibling, tagName, proposedNode.getId());
}));
}
Aggregations