.../modules/comment/src/CommentPostRenderCache.php | 35 ++++++++++------------ 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/core/modules/comment/src/CommentPostRenderCache.php b/core/modules/comment/src/CommentPostRenderCache.php index 960c06f..5262995 100644 --- a/core/modules/comment/src/CommentPostRenderCache.php +++ b/core/modules/comment/src/CommentPostRenderCache.php @@ -274,26 +274,21 @@ public function attachNewCommentsLinkMetadata(array $element, array $context) { $query = $page_number ? array('page' => $page_number) : NULL; // Attach metadata. - $element['#attached']['js'][] = array( - 'type' => 'setting', - 'data' => array( - 'comment' => array( - 'newCommentsLinks' => array( - $context['entity_type'] => array( - $context['field_name'] => array( - $context['entity_id'] => array( - 'new_comment_count' => (int) $new, - 'first_new_comment_link' => $entity->url('canonical', [ - 'query' => $query, - 'fragment' => 'new', - ]), - ), - ), - ), - ), - ), - ), - ); + $parents = [ + 'comment', + 'newCommentsLinks', + $context['entity_type'], + $context['field_name'], + $context['entity_id'] + ]; + $value = [ + 'new_comment_count' => (int) $new, + 'first_new_comment_link' => $entity->url('canonical', [ + 'query' => $query, + 'fragment' => 'new', + ]), + ]; + NestedArray::setValue($element['#attached']['drupalSettings'], $parents, $value); return $element; }