Problem/Motivation

#2486267: Attributes of a block content are applied to block itself broke what might be a fairly common workaround for the fact that attributes were pulled up to the top-level block template, putting your actual element into a child key and keeping attributes on top-level without anything else:

Steps to reproduce

From an example we use in a project:

$build = [
      '#attached' => ['library' => ['mymodule/something']],
      '#attributes' => ['class' =>  ['wrapper-class'],
      'link' => [
        '#theme' => 'mymodule_something',
        '#label' => $config['text'],
        '#attributes' => [
          'href' => '#main-content',
          'class' => $link_classes,
          'aria-label' => $config['text'],
        ] + $data,
      ],
    ];

This works fine up until 11.3 but the top-level attributes completely vanish in 11.4.

Proposed resolution

I think we can continue to pull up attributes for BC *if* $content has neither type or theme set.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3600644

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

berdir created an issue. See original summary.

berdir’s picture

Status: Active » Needs review
smustgrave’s picture

Should this have test coverage?