use of com.vaadin.client.flow.dom.DomElement.DomTokenList in project flow by vaadin.
the class SimpleElementBindingStrategy method bindClassList.
private EventRemover bindClassList(Element element, StateNode node) {
NodeList classNodeList = node.getList(NodeFeatures.CLASS_LIST);
for (int i = 0; i < classNodeList.length(); i++) {
DomApi.wrap(element).getClassList().add((String) classNodeList.get(i));
}
return classNodeList.addSpliceListener(e -> {
DomTokenList classList = DomApi.wrap(element).getClassList();
JsArray<?> remove = e.getRemove();
for (int i = 0; i < remove.length(); i++) {
classList.remove((String) remove.get(i));
}
JsArray<?> add = e.getAdd();
for (int i = 0; i < add.length(); i++) {
classList.add((String) add.get(i));
}
});
}
Aggregations