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)
| 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. |
no test coverage detected