Commit 57cf7f08 authored by alexpott's avatar alexpott
Browse files

Issue #2191543 by tim.plunkett: Fixed history_node_view_alter() overwrite all #attached on nodes.

parent d29ed30e
......@@ -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';
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment