Search in sources :

Example 1 with NodeList

use of com.gargoylesoftware.htmlunit.javascript.host.dom.NodeList in project htmlunit by HtmlUnit.

the class HTMLElement method removeNode.

/**
 * Removes this object from the document hierarchy.
 * @param removeChildren whether to remove children or no
 * @return a reference to the object that is removed
 */
@JsxFunction(IE)
public HTMLElement removeNode(final boolean removeChildren) {
    final HTMLElement parent = (HTMLElement) getParentElement();
    if (parent != null) {
        parent.removeChild(this);
        if (!removeChildren) {
            final NodeList collection = getChildNodes();
            final int length = collection.getLength();
            for (int i = 0; i < length; i++) {
                final Node object = (Node) collection.item(Integer.valueOf(0));
                parent.appendChild(object);
            }
        }
    }
    return this;
}
Also used : NodeList(com.gargoylesoftware.htmlunit.javascript.host.dom.NodeList) DomNode(com.gargoylesoftware.htmlunit.html.DomNode) Node(com.gargoylesoftware.htmlunit.javascript.host.dom.Node) JsxFunction(com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction)

Aggregations

DomNode (com.gargoylesoftware.htmlunit.html.DomNode)1 JsxFunction (com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction)1 Node (com.gargoylesoftware.htmlunit.javascript.host.dom.Node)1 NodeList (com.gargoylesoftware.htmlunit.javascript.host.dom.NodeList)1