Issue #1959110 by a.ross, fietserwin, markabur: Fixed theme_table() outputs the 'no_striping' option as an HTML attribute.
parent
d6f960c6d0
commit
f746ed8ecc
|
@ -1987,25 +1987,24 @@ function theme_table($variables) {
|
||||||
$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) {
|
||||||
$attributes = array();
|
|
||||||
|
|
||||||
// Check if we're dealing with a simple or complex row
|
// Check if we're dealing with a simple or complex row
|
||||||
if (isset($row['data'])) {
|
if (isset($row['data'])) {
|
||||||
foreach ($row as $key => $value) {
|
$cells = $row['data'];
|
||||||
if ($key == 'data') {
|
$no_striping = isset($row['no_striping']) ? $row['no_striping'] : FALSE;
|
||||||
$cells = $value;
|
|
||||||
}
|
// Set the attributes array and exclude 'data' and 'no_striping'.
|
||||||
else {
|
$attributes = $row;
|
||||||
$attributes[$key] = $value;
|
unset($attributes['data']);
|
||||||
}
|
unset($attributes['no_striping']);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$cells = $row;
|
$cells = $row;
|
||||||
|
$attributes = array();
|
||||||
|
$no_striping = FALSE;
|
||||||
}
|
}
|
||||||
if (count($cells)) {
|
if (count($cells)) {
|
||||||
// Add odd/even class
|
// Add odd/even class
|
||||||
if (empty($row['no_striping'])) {
|
if (!$no_striping) {
|
||||||
$class = $flip[$class];
|
$class = $flip[$class];
|
||||||
$attributes['class'][] = $class;
|
$attributes['class'][] = $class;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,6 +215,20 @@ class ThemeTableTestCase extends DrupalWebTestCase {
|
||||||
$this->assertRaw('<thead><tr><th>Header 1</th>', 'Table header was printed.');
|
$this->assertRaw('<thead><tr><th>Header 1</th>', 'Table header was printed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that the 'no_striping' option works correctly.
|
||||||
|
*/
|
||||||
|
function testThemeTableWithNoStriping() {
|
||||||
|
$rows = array(
|
||||||
|
array(
|
||||||
|
'data' => array(1),
|
||||||
|
'no_striping' => TRUE,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$this->content = theme('table', array('rows' => $rows));
|
||||||
|
$this->assertNoRaw('class="odd"', 'Odd/even classes were not added because $no_striping = TRUE.');
|
||||||
|
$this->assertNoRaw('no_striping', 'No invalid no_striping HTML attribute was printed.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue