/** * Detaches all element children from a node. * @param node Must not be null. * @return True iff any element children were detached by this call. */ public boolean removeAllElementChildren(final Node node) { final boolean hadChildren = node.lastChild != null; while (node.lastChild != null) { node.removeChild(node.lastChild); } return hadChildren; }
public static void insertBefore(final Node newNode, final Node referenceNode) { referenceNode.parentNode.insertBefore(newNode, referenceNode); }
void updateSubItems(final Element children) { subItems.parentNode.replaceChild(children, subItems); }
/** * Inserts the specified element into the parent of the after element if not already present. If parent already * contains child, this method does nothing. */ public static void lazyInsertAfter(Element newElement, Element after) { if (!after.parentNode.contains(newElement)) { after.parentNode.insertBefore(newElement, after.nextSibling); } }
/** * Removes the child from parent if both parent and child are not null and parent contains child. * * @return {@code true} if the the element has been removed from its parent, {@code false} otherwise. */ public static boolean failSafeRemove(Node parent, Element child) { //noinspection SimplifiableIfStatement if (parent != null && child != null && parent.contains(child)) { return parent.removeChild(child) != null; } return false; }
private static boolean isChildOfObservedNode(String attachId, List<Node> nodes, String attachUidKey) { for (int i = 0; i < nodes.size(); i++) { Node elementNode = Js.uncheckedCast(nodes.get(i)); if (Node.ELEMENT_NODE == elementNode.nodeType) { if (nonNull(elementNode.querySelector("[" + attachUidKey + "='" + attachId + "']"))) { return true; } } } return false; }
@JsOverlay public final JsObject setUserData(Object key, Object data, UserDataHandler handler) { return setUserData(Js.<JsObject>uncheckedCast(key), Js.<JsObject>uncheckedCast(data), handler); } }
public InputValueBox(String type, String label) { super(type, label); suggestionsDataList.id = getDominoId(); getInputElement().setAttribute("list", getDominoId()); getInputElement().asElement().parentNode.appendChild(suggestionsDataList); addTypeMismatchValidator(); addInvalidPatternValidator(); setAutoValidation(true); }
public KeyboardEvents(T element) { element.addEventListener(KEYDOWN, evt -> { KeyboardEvent keyboardEvent = Js.uncheckedCast(evt); String key = keyboardEvent.key.toLowerCase(); HandlerContext handlerContext = null; if (keyboardEvent.ctrlKey && ctrlHandlers.containsKey(key)) { handlerContext = ctrlHandlers.get(key); } else if (handlers.containsKey(key)) { handlerContext = handlers.get(key); } if (nonNull(handlerContext)) { handlerContext.handler.handleEvent(evt); if (handlerContext.options.preventDefault) { evt.preventDefault(); } if (handlerContext.options.stopPropagation) { evt.stopPropagation(); } } }); }
/** * Inserts the specified element into the parent of the before element if not already present. If parent already * contains child, this method does nothing. */ public static void lazyInsertBefore(Element newElement, Element before) { if (!before.parentNode.contains(newElement)) { before.parentNode.insertBefore(newElement, before); } }
private static boolean isChildOfObservedNode(String attachId, List<Node> nodes, String attachUidKey) { for (int i = 0; i < nodes.size(); i++) { Node elementNode = Js.uncheckedCast(nodes.get(i)); if (Node.ELEMENT_NODE == elementNode.nodeType) { if (nonNull(elementNode.querySelector("[" + attachUidKey + "='" + attachId + "']"))) { return true; } } } return false; }
@JsOverlay public final JsObject setUserData(Object key, Object data, UserDataHandler handler) { return setUserData(Js.<JsObject>uncheckedCast(key), Js.<JsObject>uncheckedCast(data), handler); } }
public InputValueBox(String type, String label) { super(type, label); suggestionsDataList.id = getDominoId(); getInputElement().setAttribute("list", getDominoId()); getInputElement().asElement().parentNode.appendChild(suggestionsDataList); addTypeMismatchValidator(); addInvalidPatternValidator(); setAutoValidation(true); }
public KeyboardEvents(T element) { element.addEventListener(KEYDOWN, evt -> { KeyboardEvent keyboardEvent = Js.uncheckedCast(evt); String key = keyboardEvent.key.toLowerCase(); HandlerContext handlerContext = null; if (keyboardEvent.ctrlKey && ctrlHandlers.containsKey(key)) { handlerContext = ctrlHandlers.get(key); } else if (handlers.containsKey(key)) { handlerContext = handlers.get(key); } if (nonNull(handlerContext)) { handlerContext.handler.handleEvent(evt); if (handlerContext.options.preventDefault) { evt.preventDefault(); } if (handlerContext.options.stopPropagation) { evt.stopPropagation(); } } }); }
public static void remove(final Node element) { element.parentNode.removeChild(element); } }
public static void insertAfter(final Node newNode, final Node referenceNode) { referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); }
public static void replaceElement(HTMLElement context, String identifier, HTMLElement newElement) { if (newElement == null) { throw new NullPointerException("New element must not be null in TemplateUtils.replaceElement()"); } HTMLElement oldElement = resolveElement(context, identifier); if (oldElement != null && oldElement.parentNode != null) { oldElement.parentNode.replaceChild(newElement, oldElement); } }
private Optional<Element> querySelector(final String selector) { return Optional.ofNullable(getElement().parentNode.querySelector(selector)); }
/** * Detaches all element children from a node. * @param node Must not be null. * @return True iff any element children were detached by this call. */ public boolean removeAllElementChildren(final Node node) { final boolean hadChildren = node.lastChild != null; while (node.lastChild != null) { node.removeChild(node.lastChild); } return hadChildren; }
/** Inserts the specified element into the parent of the before element. */ public static void insertBefore(Element newElement, Element before) { before.parentNode.insertBefore(newElement, before); }