Commit 5e771fa9 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#171461 by chx, ejhildreth and dvessel: empty tbody fails validation

parent 071d4b01
...@@ -1282,20 +1282,23 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) { ...@@ -1282,20 +1282,23 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) {
drupal_add_js('misc/tableheader.js'); drupal_add_js('misc/tableheader.js');
$ts = tablesort_init($header); $ts = tablesort_init($header);
$output .= ' <thead><tr>'; // HTML requires that the thead tag has tr tags in it follwed by tbody
// tags. Using ternary operator to check and see if we have any rows.
$output .= (count($rows) ? ' <thead><tr>' : ' <tr>');
foreach ($header as $cell) { foreach ($header as $cell) {
$cell = tablesort_header($cell, $header, $ts); $cell = tablesort_header($cell, $header, $ts);
$output .= _theme_table_cell($cell, TRUE); $output .= _theme_table_cell($cell, TRUE);
} }
$output .= " </tr></thead>\n"; // Using ternary operator to close the tags based on whether or not there are rows
$output .= (count($rows) ? " </tr></thead>\n" : "</tr>\n");
} }
else { else {
$ts = array(); $ts = array();
} }
// Format the table rows: // Format the table rows:
$output .= "<tbody>\n";
if (count($rows)) { if (count($rows)) {
$output .= "<tbody>\n";
$flip = array('even' => 'odd', 'odd' => 'even'); $flip = array('even' => 'odd', 'odd' => 'even');
$class = 'even'; $class = 'even';
foreach ($rows as $number => $row) { foreach ($rows as $number => $row) {
...@@ -1335,9 +1338,10 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) { ...@@ -1335,9 +1338,10 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) {
$output .= " </tr>\n"; $output .= " </tr>\n";
} }
} }
$output .= "</tbody>\n";
} }
$output .= "</tbody></table>\n"; $output .= "</table>\n";
return $output; return $output;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment