 core/includes/theme.inc         |    2 +-
 core/modules/block/block.module |    5 +++++
 core/modules/edit/edit.module   |   32 ++++----------------------------
 3 files changed, 10 insertions(+), 29 deletions(-)

diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 0d0e739..784e83e 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -2682,7 +2682,7 @@ function template_preprocess(&$variables, $hook) {
     $default_variables = _template_preprocess_default_variables();
   }
   $variables += $default_variables + array(
-    'attributes' => array(),
+    'attributes' => isset($variables['elements']['#attributes']) ? $variables['elements']['#attributes'] : array(),
     'title_attributes' => array(),
     'content_attributes' => array(),
   );
diff --git a/core/modules/block/block.module b/core/modules/block/block.module
index 57f1572..f557a00 100644
--- a/core/modules/block/block.module
+++ b/core/modules/block/block.module
@@ -545,6 +545,11 @@ function template_preprocess_block(&$variables) {
   // Create the $content variable that templates expect.
   $variables['content'] = $variables['elements']['#children'];
 
+  // Inherit the attributes set on the content of the block.
+  if (isset($variables['elements']['content']['#attributes'])) {
+    $variables['attributes'] = array_merge_recursive($variables['attributes'], $variables['elements']['content']['#attributes']);
+  }
+
   $variables['attributes']['class'][] = drupal_html_class('block-' . $variables['block']->module);
 
   // Add default class for block content.
diff --git a/core/modules/edit/edit.module b/core/modules/edit/edit.module
index 0c8eb0f..502fe43 100644
--- a/core/modules/edit/edit.module
+++ b/core/modules/edit/edit.module
@@ -14,6 +14,7 @@
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\edit\Form\EditFieldForm;
 use Drupal\Component\Utility\NestedArray;
+use Drupal\entity\Plugin\Core\Entity\EntityDisplay;
 
 /**
  * Implements hook_custom_theme().
@@ -148,35 +149,10 @@ function edit_preprocess_field(&$variables) {
 }
 
 /**
- * Implements hook_preprocess_HOOK() for node.tpl.php.
- *
- * @todo Remove this, handle in generic way: http://drupal.org/node/1972514.
- */
-function edit_preprocess_node(&$variables) {
-  $node = $variables['elements']['#node'];
-  $variables['attributes']['data-edit-entity'] = 'node/' . $node->nid;
-}
-
-/**
- * Implements hook_preprocess_HOOK() for taxonomy-term.tpl.php.
- *
- * @todo Remove this, handle in generic way: http://drupal.org/node/1972514.
+ * Implements hook_entity_view_alter().
  */
-function edit_preprocess_taxonomy_term(&$variables) {
-  $term = $variables['elements']['#term'];
-  $variables['attributes']['data-edit-entity'] = 'taxonomy_term/' . $term->id();
-}
-
-/**
- * Implements hook_preprocess_HOOK() for block.tpl.php.
- *
- * @todo Remove this, handle in generic way: http://drupal.org/node/1972514.
- */
-function edit_preprocess_block(&$variables) {
-  if (isset($variables['elements']['content']['#custom_block'])) {
-    $custom_block = $variables['elements']['content']['#custom_block'];
-    $variables['attributes']['data-edit-entity'] = 'custom_block/' . $custom_block->id();
-  }
+function edit_entity_view_alter(&$build, EntityInterface $entity, EntityDisplay $display) {
+  $build['#attributes']['data-edit-entity'] = $entity->entityType() . '/' . $entity->id();
 }
 
 /**
