I just wrote a preprecessor to transform the ids on blocks to classes:

<?php
/*
 * Implements hook_preprocess_block().
 */
function template_preprocess_block(&$variables) {
  if (isset($variables['attributes']['id'])) {
    $variables['attributes']['class'] = $variables['attributes']['id'];
    unset($variables['attributes']['id']);
  }
}
?>

Having ids in the markup is against D8 standards, right?

Files: 

Comments

Cottser’s picture

Issue tags: +Twig, +frontend
Related issues: +#1982244: Markup for: block module

Adding a related issue, I can't recall if removing IDs was discussed on this one. I'm not saying this is a duplicate, small pieces are good (the issue I'm adding is over 2 years old and still open).

My suggestion for now would be to add a patch that removes the ID at the source and see what tests fail :)

Cottser’s picture

And another one that might be worth a look that is talking about updating the IDs.

joelpittet’s picture

Version: 8.0.x-dev » 8.1.x-dev

There is a requirement for a couple things I believe for ID's on block but no reason why we couldn't use a custom data attribute that gets added.

Eg. contextual links can inject a data-contextual-id="search-block" on when it has permissions and is enabled.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

joelpittet’s picture

Status: Active » Needs review
FileSize
649 bytes

Curious how testbot reacts to this. Maybe we could do this in a BC way with config and an update hook?

Status: Needs review » Needs work

The last submitted patch, 6: 2508357-6.patch, failed testing.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.