diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 94c519e..7ce8151 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -449,9 +449,6 @@ function template_preprocess_views_view_table(&$variables) { // Create a second variable so we can easily find what fields we have and // what the CSS classes should be. $variables['fields'][$field] = Html::cleanCssIdentifier($field); - if ($active == $field) { - $variables['fields'][$field] .= ' is-active'; - } // Render the header labels. if ($field == $column && empty($fields[$field]->options['exclude'])) { @@ -487,19 +484,21 @@ function template_preprocess_views_view_table(&$variables) { $variables['header'][$field]['default_classes'] = $fields[$field]->options['element_default_classes']; // Set up the header label class. - $variables['header'][$field]['attributes'] = array(); - $class = $fields[$field]->elementLabelClasses(0); - if ($class) { - $variables['header'][$field]['attributes']['class'][] = $class; + $variables['header'][$field]['attributes'] = new Attribute(); + if ($class = $fields[$field]->elementLabelClasses(0)) { + $variables['header'][$field]['attributes']->addClass($class); + } + if ($active == $field) { + $variables['header'][$field]['attributes']->addClass('is-active'); } // Add responsive header classes. if (!empty($options['info'][$field]['responsive'])) { - $variables['header'][$field]['attributes']['class'][] = $options['info'][$field]['responsive']; + $variables['header'][$field]['attributes']->addClass($options['info'][$field]['responsive']); $responsive = TRUE; } // Add a CSS align class to each field if one was set. if (!empty($options['info'][$field]['align'])) { - $variables['header'][$field]['attributes']['class'][] = Html::cleanCssIdentifier($options['info'][$field]['align']); + $variables['header'][$field]['attributes']->addClass(Html::cleanCssIdentifier($options['info'][$field]['align'])); } // Add a header label wrapper if one was selected. if ($variables['header'][$field]['content']) { @@ -514,13 +513,6 @@ function template_preprocess_views_view_table(&$variables) { if (!empty($variables['header'][$field]['content'])) { $has_header_labels = TRUE; } - - $variables['header'][$field]['attributes'] = new Attribute($variables['header'][$field]['attributes']); - } - - // Add a CSS align class to each field if one was set. - if (!empty($options['info'][$field]['align'])) { - $variables['fields'][$field] .= ' ' . Html::cleanCssIdentifier($options['info'][$field]['align']); } // Render each field into its appropriate column. @@ -543,16 +535,25 @@ function template_preprocess_views_view_table(&$variables) { // Add field classes. if (!isset($column_reference['attributes'])) { - $column_reference['attributes'] = array(); + $column_reference['attributes'] = new Attribute(); } if ($classes = $fields[$field]->elementClasses($num)) { - $column_reference['attributes']['class'][] = $classes; + $column_reference['attributes']->addClass($classes); + } + + if ($active == $field) { + $column_reference['attributes']->addClass('is-active'); + } + + // Add a CSS align class to each field if one was set. + if (!empty($options['info'][$field]['align'])) { + $column_reference['attributes']->addClass(Html::cleanCssIdentifier($options['info'][$field]['align'])); } // Add responsive header classes. if (!empty($options['info'][$field]['responsive'])) { - $column_reference['attributes']['class'][] = $options['info'][$field]['responsive']; + $column_reference['attributes']->addClass($options['info'][$field]['responsive']); } // Improves accessibility of complex tables. @@ -583,7 +584,6 @@ function template_preprocess_views_view_table(&$variables) { } } } - $column_reference['attributes'] = new Attribute($column_reference['attributes']); } // Remove columns if the "empty_column" option is checked and the