Index: tables.uncompressed.js =================================================================== --- tables.uncompressed.js (revision 7018) +++ tables.uncompressed.js (working copy) @@ -139,63 +139,65 @@ h = t.find('thead'), bratz; - if (h.length === 0 && b.firstChild) { - // No THEAD, but TBODY has some rows - if (hrc !== undefined) { - if (hrc > $(b).children().length) { - hrc = $(b).children().length; + if (typeof(b) !== 'undefined' ) { + if ( h.length === 0 && b.firstChild) { + // No THEAD, but TBODY has some rows + if (hrc !== undefined) { + if (hrc > $(b).children().length) { + hrc = $(b).children().length; + } + } else { + // See if we can find header rows by groping + hrc = 0; + var fc = b.firstChild; + while (fc && fc.firstChild && fc.firstChild.tagName == 'TH') { + hrc++; + fc = fc.nextSibling; + } } - } else { - // See if we can find header rows by groping - hrc = 0; - var fc = b.firstChild; - while (fc && fc.firstChild && fc.firstChild.tagName == 'TH') { - hrc++; - fc = fc.nextSibling; + if (hrc > 0) { + bodies.before(""); + h = t.find('thead'); + while (hrc--) { + bratz = $(b).children(); + h.append($(bratz[0]).remove()); + } } } - if (hrc > 0) { - bodies.before(""); - h = t.find('thead'); - while (hrc--) { - bratz = $(b).children(); - h.append($(bratz[0]).remove()); - } + + var f = t.find('tfoot'); + if (f.length !== 0 && f.children().length === 0) { + // There's a bug in Render.pm that makes it generate + // an empty tfoot even if there are footer rows + // Remove empty tfoot and recompute + f.remove(); + f = []; } - } - - var f = t.find('tfoot'); - if (f.length !== 0 && f.children().length === 0) { - // There's a bug in Render.pm that makes it generate - // an empty tfoot even if there are footer rows - // Remove empty tfoot and recompute - f.remove(); - f = []; - } - if (f.length === 0 && $(b).children().length > 0) { - // No TFOOT, are there enough rows in the body? - if (frc !== undefined) { - if (frc > $(b).children().length) { - frc = $(b).children().length; + if (f.length === 0 && $(b).children().length > 0) { + // No TFOOT, are there enough rows in the body? + if (frc !== undefined) { + if (frc > $(b).children().length) { + frc = $(b).children().length; + } + } else { + // Footer rows not explicitly defined - see + // if we can find footer rows by groping + frc = 0; + var lc = b.lastChild; + while (lc && lc.firstChild && lc.firstChild.tagName == 'TH') { + frc++; + lc = lc.previousSibling; + } } - } else { - // Footer rows not explicitly defined - see - // if we can find footer rows by groping - frc = 0; - var lc = b.lastChild; - while (lc && lc.firstChild && lc.firstChild.tagName == 'TH') { - frc++; - lc = lc.previousSibling; + if (frc > 0) { + bodies.after("
"); + f = t.find('tfoot'); + while (frc--) { + bratz = $(b).children(); + f.append($(bratz[bratz.length - 1]).remove()); + } } } - if (frc > 0) { - bodies.after(""); - f = t.find('tfoot'); - while (frc--) { - bratz = $(b).children(); - f.append($(bratz[bratz.length - 1]).remove()); - } - } } },