diff --git a/core/includes/theme.inc b/core/includes/theme.inc index c8b88f2..0a74451 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1784,14 +1784,14 @@ function theme_mark($variables) { function template_preprocess_item_list(&$variables) { $variables['title'] = (string) $variables['title']; - // Prepare for adding classes to each item. - $num_items = count($variables['items']); - $i = 0; foreach ($variables['items'] as &$item) { - $i++; $attributes = array(); // If the item value is an array, then it is a render array. if (is_array($item)) { + // List items support attributes via the 'attributes' property. + if (isset($item['attributes']) && is_array($item['attributes'])) { + $attributes = $item['attributes']; + } // Determine whether there are any child elements in the item that are not // fully-specified render arrays. If there are any, then the child // elements present nested lists and we automatically inherit the render @@ -1823,9 +1823,11 @@ function template_preprocess_item_list(&$variables) { } else { // Turn the item into an array if it wasn't one already. - $item = array('#markup' => $item); + $item = array('value' => $item); } + // Store item attributes for Twig. + $item['attributes'] = new Attribute($attributes); } } diff --git a/core/modules/system/templates/item-list.html.twig b/core/modules/system/templates/item-list.html.twig index 3315c0b..2936224 100644 --- a/core/modules/system/templates/item-list.html.twig +++ b/core/modules/system/templates/item-list.html.twig @@ -30,7 +30,7 @@