diff --git a/core/includes/theme.inc b/core/includes/theme.inc index b1f4d36..654803c 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1503,29 +1503,23 @@ function template_preprocess_table(&$variables) { // Format the table columns: if (!empty($variables['colgroups'])) { - foreach ($variables['colgroups'] as $colgroup_key => &$colgroup) { - $colgroup_attributes = new Attribute(); - + foreach ($variables['colgroups'] as &$colgroup) { // Check if we're dealing with a simple or complex column if (isset($colgroup['data'])) { - foreach ($colgroup as $key => $value) { - if ($key == 'data') { - $cols = $value; - } - else { - $colgroup_attributes[$key] = $value; - } - } + $cols = $colgroup['data']; + unset($colgroup['data']); + $colgroup_attributes = $colgroup; } else { $cols = $colgroup; + $colgroup_attributes = array(); } $colgroup = array(); - $colgroup['attributes'] = $colgroup_attributes; + $colgroup['attributes'] = new Attribute($colgroup_attributes); + $colgroup['cols'] = array(); - // Build colgroups and assign attributes + // Build columns. if (is_array($cols) && !empty($cols)) { - $colgroup['cols'] = array(); foreach ($cols as $col_key => $col) { $colgroup['cols'][$col_key]['attributes'] = new Attribute($col); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php index f9b8631..6b9c5ef 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php @@ -133,6 +133,7 @@ function testThemeTableHeaderCellOption() { '#rows' => $rows, ); $this->render($table); + $this->removeWhiteSpace(); $this->assertRaw('