From 5e771fa917f16acbcdce96f69d0f0af634eacbe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Thu, 4 Oct 2007 17:53:56 +0000 Subject: #171461 by chx, ejhildreth and dvessel: empty tbody fails validation --- includes/theme.inc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/theme.inc b/includes/theme.inc index 04621ca72..9e15f21e6 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1282,20 +1282,23 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) { drupal_add_js('misc/tableheader.js'); $ts = tablesort_init($header); - $output .= ' '; + // 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) ? ' ' : ' '); foreach ($header as $cell) { $cell = tablesort_header($cell, $header, $ts); $output .= _theme_table_cell($cell, TRUE); } - $output .= " \n"; + // Using ternary operator to close the tags based on whether or not there are rows + $output .= (count($rows) ? " \n" : "\n"); } else { $ts = array(); } // Format the table rows: - $output .= "\n"; if (count($rows)) { + $output .= "\n"; $flip = array('even' => 'odd', 'odd' => 'even'); $class = 'even'; foreach ($rows as $number => $row) { @@ -1335,9 +1338,10 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) { $output .= " \n"; } } + $output .= "\n"; } - $output .= "\n"; + $output .= "\n"; return $output; } -- cgit v1.2.3