diff -u b/core/includes/common.inc b/core/includes/common.inc --- b/core/includes/common.inc +++ b/core/includes/common.inc @@ -33,7 +33,7 @@ use Drupal\Core\Template\Attribute; use Drupal\Core\Render\Element; use Drupal\Core\Session\AnonymousUserSession; -use Drupal\Core\Template\TemplateAttachmentManager; +use Drupal\Core\Template\AttachmentManager; /** * @defgroup php_wrappers PHP wrapper functions @@ -1672,9 +1672,9 @@ ); // Check for attachments added from a template. - if ($template_attachments = TemplateAttachmentManager::getAttachments('library')) { + if ($template_attachments = AttachmentManager::getAttachments('library')) { $elements['#attached']['library'] = array_merge($elements['#attached']['library'], $template_attachments); - TemplateAttachmentManager::clearAttachments('library'); + AttachmentManager::clearAttachments('library'); } // Add the libraries first. reverted: --- b/core/lib/Drupal/Core/Template/TemplateAttachmentManager.php +++ /dev/null @@ -1,54 +0,0 @@ -assertArrayEquals(array(), $result); + $attachments = array( + 'special-css-library-1', + 'special-js-library-1', + ); + AttachmentManager::addAttachments($attachments); + $result = AttachmentManager::getAttachments(); + $this->assertTrue(in_array($attachments[0], $result)); + $this->assertTrue(in_array($attachments[1], $result)); + $new_attachment = 'new-css-library'; + AttachmentManager::addAttachments($new_attachment); + $result = AttachmentManager::getAttachments(); + $this->assertTrue(in_array($new_attachment, $result)); + $this->assertEquals(3, count($result)); + AttachmentManager::clearAttachments(); + $result = AttachmentManager::getAttachments(); + $this->assertArrayEquals(array(), $result); + } + +}