From 57cf7f081c836cf8fb2058208fe8c9fd48e9de24 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Thu, 10 Jul 2014 10:39:05 +0100
Subject: [PATCH] Issue #2191543 by tim.plunkett: Fixed
 history_node_view_alter() overwrite all #attached on nodes.

---
 core/modules/history/history.module | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/core/modules/history/history.module b/core/modules/history/history.module
index 4a2b2e3e4c5f..06e82d89e03f 100644
--- a/core/modules/history/history.module
+++ b/core/modules/history/history.module
@@ -135,20 +135,14 @@ function history_cron() {
 function history_node_view_alter(array &$build, EntityInterface $node, EntityViewDisplayInterface $display) {
   // Update the history table, stating that this user viewed this node.
   if (($display->originalMode === 'full') && \Drupal::currentUser()->isAuthenticated()) {
-    $build['#attached'] = array(
-      'js' => array(
-        // When the window's "load" event is triggered, mark the node as read.
-        // This still allows for Drupal behaviors (which are triggered on the
-        // "DOMContentReady" event) to add "new" and "updated" indicators.
-        array(
-          'data' => 'window.addEventListener("load",function(){Drupal.history.markAsRead(' . $node->id() . ');},false);',
-          'type' => 'inline',
-        ),
-      ),
-      'library' => array(
-        'history/drupal.history',
-      ),
+    // When the window's "load" event is triggered, mark the node as read.
+    // This still allows for Drupal behaviors (which are triggered on the
+    // "DOMContentReady" event) to add "new" and "updated" indicators.
+    $build['#attached']['js'][] = array(
+      'data' => 'window.addEventListener("load",function(){Drupal.history.markAsRead(' . $node->id() . ');},false);',
+      'type' => 'inline',
     );
+    $build['#attached']['library'][] = 'history/drupal.history';
   }
 
 }
-- 
GitLab