/** * Returns the first element within the document that matches the specified group of selectors. * @param selectors one or more CSS selectors separated by commas * @param <N> the node type * @return null if no matches are found; otherwise, it returns the first matching element */ @SuppressWarnings("unchecked") public <N extends DomNode> N querySelector(final String selectors) { final DomNodeList<DomNode> list = querySelectorAll(selectors); if (!list.isEmpty()) { return (N) list.get(0); } return null; }
/** * Returns the first element within the document that matches the specified group of selectors. * @param selectors one or more CSS selectors separated by commas * @param <N> the node type * @return null if no matches are found; otherwise, it returns the first matching element */ @SuppressWarnings("unchecked") public <N extends DomNode> N querySelector(final String selectors) { final DomNodeList<DomNode> list = querySelectorAll(selectors); if (!list.isEmpty()) { return (N) list.get(0); } return null; }
/** * Returns the node to type into. * @return the node */ private DomNode getDoTypeNode() { DomNode node = null; final HTMLElement scriptElement = getScriptableObject(); if (scriptElement.isIsContentEditable() || "on".equals(((Document) scriptElement.getOwnerDocument()).getDesignMode())) { final DomNodeList<DomNode> children = getChildNodes(); if (!children.isEmpty()) { final DomNode lastChild = children.get(children.size() - 1); if (lastChild instanceof DomText) { node = lastChild; } else if (lastChild instanceof HtmlElement) { node = lastChild; } } if (node == null) { final DomText domText = new DomText(getPage(), ""); appendChild(domText); node = domText; } } return node; }
/** * Returns the node to type into. * @return the node */ private DomNode getDoTypeNode() { DomNode node = null; final HTMLElement scriptElement = getScriptableObject(); if (scriptElement.isIsContentEditable() || "on".equals(((Document) scriptElement.getOwnerDocument()).getDesignMode())) { final DomNodeList<DomNode> children = getChildNodes(); if (!children.isEmpty()) { final DomNode lastChild = children.get(children.size() - 1); if (lastChild instanceof DomText) { node = lastChild; } else if (lastChild instanceof HtmlElement) { node = lastChild; } } if (node == null) { final DomText domText = new DomText(getPage(), ""); appendChild(domText); node = domText; } } return node; }