lib/tables.js
function createBody(ast) {
  if (util.hasType(ast, 'tbody')) return;
  var open = ast.nodes.shift();
  var close = ast.nodes.pop();
  var started;
  var nodes = [];
  var tbody;

  var len = ast.nodes.length;
  var idx = -1;
  while (++idx < len) {
    var node = ast.nodes[idx];
    if (node.type === 'tr' && !started) {
      started = true;
      tbody = { type: 'tbody', nodes: [] };
      define(tbody, 'parent', ast);
      nodes.push(tbody);
    }

    if (started) {
      define(node, 'parent', tbody);
      tbody.nodes.push(node);
    } else {
      nodes.push(node);
    }
  }

  if (tbody) {
    util.wrapNodes(tbody, Node);
  }

  ast.nodes = [open];
  ast.nodes = ast.nodes.concat(nodes);
  ast.nodes.push(close);
}
function createBody(ast) {
  if (util.hasType(ast, 'tbody')) return;
  var open = ast.nodes.shift();
  var close = ast.nodes.pop();
  var started;
  var nodes = [];
  var tbody;

  var len = ast.nodes.length;
  var idx = -1;
  while (++idx < len) {
    var node = ast.nodes[idx];
    if (node.type === 'tr' && !started) {
      started = true;
      tbody = { type: 'tbody', nodes: [] };
      define(tbody, 'parent', ast);
      nodes.push(tbody);
    }

    if (started) {
      define(node, 'parent', tbody);
      tbody.nodes.push(node);
    } else {
      nodes.push(node);
    }
  }

  if (tbody) {
    util.wrapNodes(tbody, Node);
  }

  ast.nodes = [open];
  ast.nodes = ast.nodes.concat(nodes);
  ast.nodes.push(close);
}
function createBody ( ast ) { if ( util . hasType ( ast , 'tbody' ) ) return ; var open = ast . nodes . shift ( ) ; var close = ast . nodes . pop ( ) ; var started ; var nodes = [ ] ; var tbody ; var len = ast . nodes . length ; var idx = - 1 ; while ( ++ idx < len ) { var node = ast . nodes [ idx ] ; if ( node . type === 'tr' && ! started ) { started = true ; tbody = { type : 'tbody' , nodes : [ ] } ; define ( tbody , 'parent' , ast ) ; nodes . push ( tbody ) ; } if ( started ) { define ( node , 'parent' , tbody ) ; tbody . nodes . push ( node ) ; } else { nodes . push ( node ) ; } } if ( tbody ) { util . wrapNodes ( tbody , Node ) ; } ast . nodes = [ open ] ; ast . nodes = ast . nodes . concat ( nodes ) ; ast . nodes . push ( close ) ; }
Add `tbody` nodes if they don't exist
Add tbody nodes if they don t exist