core/lib/Drupal/Core/Template/TwigExtension.php | 30 ++++++++++++++----------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index 8c6abcc..a30b36e 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -482,19 +482,23 @@ public function escapeFilter(\Twig_Environment $env, $arg, $strategy = 'html', $ * @see \Drupal\Core\Render\RendererInterface::render() */ protected function bubbleArgMetadata($arg) { - if ($arg instanceof CacheableDependencyInterface || $arg instanceof AttachmentsInterface) { - $arg_bubbleable = []; - if ($arg instanceof CacheableDependencyInterface) { - $arg_bubbleable['#cache']['contexts'] = $arg->getCacheContexts(); - $arg_bubbleable['#cache']['tags'] = $arg->getCacheTags(); - $arg_bubbleable['#cache']['max-age'] = $arg->getCacheMaxAge(); - } - if ($arg instanceof AttachmentsInterface) { - $arg_bubbleable['#attached'] = $arg->getAttachments(); - } - if ($arg_bubbleable) { - $this->renderer->render($arg_bubbleable); - } + // If it's a renderable, then it'll be up to the generated render array it + // returns to contain the necessary cacheability & attachment metadata. + if ($arg instanceof RenderableInterface) { + return; + } + + $arg_bubbleable = []; + if ($arg instanceof CacheableDependencyInterface) { + $arg_bubbleable['#cache']['contexts'] = $arg->getCacheContexts(); + $arg_bubbleable['#cache']['tags'] = $arg->getCacheTags(); + $arg_bubbleable['#cache']['max-age'] = $arg->getCacheMaxAge(); + } + if ($arg instanceof AttachmentsInterface) { + $arg_bubbleable['#attached'] = $arg->getAttachments(); + } + if ($arg_bubbleable) { + $this->renderer->render($arg_bubbleable); } }