Insert an element as the first child node of another

@param  {Element} child   Element to insert
@param  {Element} parent Element to insert child into
@private
@function insertElFirst
191916
function insertElFirst(child, parent) {
  if (parent.firstChild) {
    parent.insertBefore(child, parent.firstChild);
  } else {
    parent.appendChild(child);
  }
}
411380
function (node, newNode) {
        return node.nextSibling ? node.parentNode.insertBefore(newNode, node.nextSibling):
            node.parentNode.appendChild(newNode);
    }
545682
public Element appendChild(Node child) {
        Validate.notNull(child);

        // was - Node#addChildren(child). short-circuits an array create and a loop.
        reparentChild(child);
        ensureChildNodes();
        childNodes.add(child);
        child.setSiblingIndex(childNodes.size() - 1);
        return this;
    }
742440
public void addChildElement(Node element) {
        element.setParent(this);
        emptyElementTag = false; // can't be an empty element tag if you attach child elements
        childElements.add(element);
    }
582640
def add_child(self, child):
        ''''''
        super(RootNode, self).add_child(child)
        child.attr_wrapper = self.attr_wrapper
714311
function (parent, nodes) {
  for (var i = nodes.length - 1; i >= 0; i--) {
    parent.insertBefore(nodes[nodes.length - 1], parent.firstChild)
  }
}
461820
private boolean firstChild(Parse child, Parse parent) {
    return ParserME.collapsePunctuation(parent.getChildren(),punctSet)[0] == child;
  }
85229
function prependTo(newNode, parentNode, siblingNode) {
  parentNode.insertBefore(newNode, siblingNode || parentNode.firstChild);
}
52137
function(parent) {
		var temp = this.document.createElement(parent.nodeName);
		temp.innerHTML = this.xelement.outerHTML;
		return temp.firstChild;
	}
579855
function insertOrAppend(container, pos, el) {
    var childs = container.childNodes;
    if (pos < childs.length) {
      var refNode = childs[pos];
      container.insertBefore(el, refNode);
    } else {
      container.appendChild(el);
    }
  }
395520
function _appendNode(parent, child) {
  var parentName = _getHTMLNodeName(parent);

  var childName = _getHTMLNodeName(child);

  if (doc.createStyleSheet) {
    if (parentName === 'script') {
      parent.text = child.nodeValue;
      return;
    }

    if (parentName === 'style') {
      parent.cssText = child.nodeValue; // This will not apply it--just make it available within the DOM cotents

      return;
    }
  }

  if (parentName === 'template') {
    parent.content.appendChild(child);
    return;
  }

  try {
    parent.appendChild(child); // IE9 is now ok with this
  } catch (e) {
    if (parentName === 'select' && childName === 'option') {
      try {
        // Since this is now DOM Level 4 standard behavior (and what IE7+ can handle), we try it first
        parent.add(child);
      } catch (err) {
        // DOM Level 2 did require a second argument, so we try it too just in case the user is using an older version of Firefox, etc.
        parent.add(child, null); // IE7 has a problem with this, but IE8+ is ok
      }

      return;
    }

    throw e;
  }
}
710286
function (child, index) {
            var indexOffset = this._calculateIndexOffsetForChild(child);
            this.$parent.addChild(child, {childIndex: index + indexOffset});
        }
1191438
function(child, parent) {
  var ctor = function(){ };
  ctor.prototype = parent.prototype;
  child.__super__ = parent.prototype;
  child.prototype = new ctor();
  child.prototype.constructor = child;
  child.fn = child.prototype
}
127208
def add_child(self, node):
        """"""
        node._parent = self
        self._children.append(node)
537769
function addChildAt(child, index) {
         if (index >= 0 && index < this.children.length) {
           if (child.ancestor instanceof me.Container) {
             child.ancestor.removeChildNow(child);
           } else {
             // only allocate a GUID if the object has no previous ancestor
             // (e.g. move one child from one container to another)
             if (child.isRenderable) {
               // allocated a GUID value
               child.GUID = me.utils.createGUID();
             }
           }

           child.ancestor = this;
           this.children.splice(index, 0, child);

           if (typeof child.onActivateEvent === "function" && this.isAttachedToRoot()) {
             child.onActivateEvent();
           }

           this.onChildChange.call(this, index);
           return child;
         } else {
           throw new Error("Index (" + index + ") Out Of Bounds for addChildAt()");
         }
       }
583266
public static void appendChild(Document doc, Element parentElement, String elementName, String elementValue) {
        Element child = doc.createElement(elementName);
        Text text = doc.createTextNode(elementValue);
        child.appendChild(text);
        parentElement.appendChild(child);
    }
934879
public void addFirstChild( PlanNode child ) {
        assert child != null;
        this.children.addFirst(child);
        child.removeFromParent();
        child.parent = this;
    }