Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

theme_item_list()'s $items variable has been changed to only accept either a plain string as item, or a render array.

The behavior for string values is unchanged. This change only affects code that

  • specifies custom attributes for the list item. (not the content within)
  • renders nested/child lists.

Drupal 7

$items = array();
// A simple string item (unchanged).
$items[] = 'Simple string';
// Set custom attributes for a list item.
$items[] = array(
  'data' => 'Custom item',
  'class' => array('custom-item-class'),
);
// Add an item with a nested/child list.
$items[] = array(
  'data' => 'Parent item',
  'children' => array(
    'Simple string child',
    array(
      'data' => 'Second child item with custom attributes',
      'class' => array('custom-child-item-class'),
    ),
  ),
);
$output = theme('item_list', array('items' => $items));

Drupal 8

$items = array();
// A simple string item (unchanged).
$items[] = 'Simple string';
// A simple string item as render array (new, same effect/output as previous).
$items[] = array(
  '#markup' => 'Simple string',
);
// Set custom attributes for a list item.
$items[] = array(
  '#markup' => 'Custom item',
  '#wrapper_attributes' => array(
    'class' => array('custom-item-class'),
  ),
);
// Add an item with a nested/child list.
$items[] = array(
  '#markup' => 'Parent item',
  'children' => array(
    'Simple string child',
    array(
      '#markup' => 'Second child item with custom attributes',
      '#wrapper_attributes' => array(
        'class' => array('custom-child-item-class'),
      ),
    ),
  ),
);
$output = theme('item_list', array('items' => $items));

A list item and also a nested/child list item can be any kind of render array.

Note that render array attributes for nested/child lists are automatically inherited and do not have to be specified manually — i.e., as in Drupal 7, nested child lists automatically use the same theme_item_list() properties and attributes, unless explicitly overridden.

Impacts: 
Module developers
Themers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done