Exemplo n.º 1
0
void prependChild(Node *node, Node *chd) {
  Node *fc;

  if (!chd)
    return;

  fc = firstChild(node);
  if (fc) {
    set_nextSibling(chd, fc);
    set_previousSibling(fc, chd);
  }
  set_firstChild(node, chd);
  while (chd) {
    set_parentNode(chd, node);
    chd = nextSibling(chd);
  }
}
Exemplo n.º 2
0
void
appendChild(Node *node, Node *chd) {
  Node *lc;

  if (!chd) return;

  lc = lastChild(node);
  if (!lc) {
    set_firstChild(node,chd);
  } else {
    set_nextSibling(lc,chd);
    set_previousSibling(chd,lc);
  }
  while (chd) {
    lc = chd;
    set_parentNode(chd,node);
    chd = nextSibling(chd);
  }
  set_lastChild(node,lc);
}