MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / prepend

Method prepend

src/main/java/org/htmlunit/javascript/host/dom/Node.java:1082–1101  ·  view source on GitHub ↗

Inserts a set of Node objects or string objects before the first child of the Element. String objects are inserted as equivalent Text nodes. @param context the context @param thisObj this object @param args the arguments @param function the function

(final Context context, final Scriptable thisObj, final Object[] args,
            final Function function)

Source from the content-addressed store, hash-verified

1080 * @param function the function
1081 */
1082 protected static void prepend(final Context context, final Scriptable thisObj, final Object[] args,
1083 final Function function) {
1084 if (!(thisObj instanceof Node thisNode)) {
1085 throw JavaScriptEngine.typeError("Illegal invocation");
1086 }
1087
1088 final DomNode thisDomNode = thisNode.getDomNodeOrDie();
1089 final DomNode firstChild = thisDomNode.getFirstChild();
1090
1091 for (final Object arg : args) {
1092 final Node node = toNodeOrTextNode(thisNode, arg);
1093 final DomNode newNode = node.getDomNodeOrDie();
1094 if (firstChild == null) {
1095 thisDomNode.appendChild(newNode);
1096 }
1097 else {
1098 firstChild.insertBefore(newNode);
1099 }
1100 }
1101 }
1102
1103 /**
1104 * Replaces the existing children of a Node with a specified new set of children.

Callers 2

prependMethod · 0.95
prependMethod · 0.95

Implementers 1

DomNodesrc/main/java/org/htmlunit/html/DomNod

Calls 6

typeErrorMethod · 0.95
getFirstChildMethod · 0.95
toNodeOrTextNodeMethod · 0.95
appendChildMethod · 0.95
insertBeforeMethod · 0.95
getDomNodeOrDieMethod · 0.45

Tested by

no test coverage detected