Java Code Examples for com.gargoylesoftware.htmlunit.html.DomNode#removeAllChildren()
The following examples show how to use
com.gargoylesoftware.htmlunit.html.DomNode#removeAllChildren() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Element.java From htmlunit with Apache License 2.0 | 6 votes |
/** * Replaces all child elements of this element with the supplied value. * @param value the new value for the contents of this element */ @JsxSetter({CHROME, FF, FF68, FF60}) public void setInnerHTML(final Object value) { final DomNode domNode; try { domNode = getDomNodeOrDie(); } catch (final IllegalStateException e) { Context.throwAsScriptRuntimeEx(e); return; } domNode.removeAllChildren(); getWindow().clearComputedStylesUpToRoot(this); final boolean addChildForNull = getBrowserVersion().hasFeature(JS_INNER_HTML_ADD_CHILD_FOR_NULL_VALUE); if ((value == null && addChildForNull) || (value != null && !"".equals(value))) { final String valueAsString = Context.toString(value); parseHtmlSnippet(domNode, valueAsString); } }
Example 2
Source File: Element.java From HtmlUnit-Android with Apache License 2.0 | 6 votes |
/** * Replaces all child elements of this element with the supplied value. * @param value the new value for the contents of this element */ @JsxSetter({CHROME, FF}) public void setInnerHTML(final Object value) { final DomNode domNode; try { domNode = getDomNodeOrDie(); } catch (final IllegalStateException e) { Context.throwAsScriptRuntimeEx(e); return; } domNode.removeAllChildren(); final boolean addChildForNull = getBrowserVersion().hasFeature(JS_INNER_HTML_ADD_CHILD_FOR_NULL_VALUE); if ((value == null && addChildForNull) || (value != null && !"".equals(value))) { final String valueAsString = Context.toString(value); parseHtmlSnippet(domNode, valueAsString); } }
Example 3
Source File: HTMLElement.java From htmlunit with Apache License 2.0 | 5 votes |
/** * The worker for setInnerText. * @param value the new value for the contents of this node */ protected void setInnerTextImpl(final String value) { final DomNode domNode = getDomNodeOrDie(); domNode.removeAllChildren(); if (value != null && !value.isEmpty()) { domNode.appendChild(new DomText(domNode.getPage(), value)); } }
Example 4
Source File: HTMLElement.java From HtmlUnit-Android with Apache License 2.0 | 5 votes |
/** * The worker for setInnerText. * @param value the new value for the contents of this node */ protected void setInnerTextImpl(final String value) { final DomNode domNode = getDomNodeOrDie(); domNode.removeAllChildren(); if (value != null && !value.isEmpty()) { domNode.appendChild(new DomText(domNode.getPage(), value)); } }
Example 5
Source File: Element.java From htmlunit with Apache License 2.0 | 4 votes |
/** * Replaces this element (including all child elements) with the supplied value. * @param value the new value for replacing this element */ @JsxSetter({CHROME, FF, FF68, FF60}) public void setOuterHTML(final Object value) { final DomNode domNode = getDomNodeOrDie(); final DomNode parent = domNode.getParentNode(); if (null == parent) { if (getBrowserVersion().hasFeature(JS_OUTER_HTML_REMOVES_CHILDREN_FOR_DETACHED)) { domNode.removeAllChildren(); } if (getBrowserVersion().hasFeature(JS_OUTER_HTML_THROWS_FOR_DETACHED)) { throw Context.reportRuntimeError("outerHTML is readonly for detached nodes"); } return; } if (value == null && !getBrowserVersion().hasFeature(JS_OUTER_HTML_NULL_AS_STRING)) { domNode.remove(); return; } final String valueStr = Context.toString(value); if (valueStr.isEmpty()) { domNode.remove(); return; } final DomNode nextSibling = domNode.getNextSibling(); domNode.remove(); final DomNode target; final boolean append; if (nextSibling != null) { target = nextSibling; append = false; } else { target = parent; append = true; } final DomNode proxyDomNode = new ProxyDomNode(target.getPage(), target, append); parseHtmlSnippet(proxyDomNode, valueStr); }
Example 6
Source File: Element.java From HtmlUnit-Android with Apache License 2.0 | 4 votes |
/** * Replaces this element (including all child elements) with the supplied value. * @param value the new value for replacing this element */ @JsxSetter({CHROME, FF}) public void setOuterHTML(final Object value) { final DomNode domNode = getDomNodeOrDie(); final DomNode parent = domNode.getParentNode(); if (null == parent) { if (getBrowserVersion().hasFeature(JS_OUTER_HTML_REMOVES_CHILDREN_FOR_DETACHED)) { domNode.removeAllChildren(); } if (getBrowserVersion().hasFeature(JS_OUTER_HTML_THROWS_FOR_DETACHED)) { throw Context.reportRuntimeError("outerHTML is readonly for detached nodes"); } return; } if (value == null && !getBrowserVersion().hasFeature(JS_OUTER_HTML_NULL_AS_STRING)) { domNode.remove(); return; } final String valueStr = Context.toString(value); if (valueStr.isEmpty()) { domNode.remove(); return; } final DomNode nextSibling = domNode.getNextSibling(); domNode.remove(); final DomNode target; final boolean append; if (nextSibling != null) { target = nextSibling; append = false; } else { target = parent; append = true; } final DomNode proxyDomNode = new ProxyDomNode(target.getPage(), target, append); parseHtmlSnippet(proxyDomNode, valueStr); }