.../Drupal/Core/Render/PlaceholderGenerator.php | 2 -- core/lib/Drupal/Core/Render/Renderer.php | 1 - core/modules/big_pipe/src/Render/BigPipe.php | 7 ----- .../src/Render/Placeholder/BigPipeStrategy.php | 35 ++++++++++------------ 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/core/lib/Drupal/Core/Render/PlaceholderGenerator.php b/core/lib/Drupal/Core/Render/PlaceholderGenerator.php index fe50b33..82e9d09 100644 --- a/core/lib/Drupal/Core/Render/PlaceholderGenerator.php +++ b/core/lib/Drupal/Core/Render/PlaceholderGenerator.php @@ -81,8 +81,6 @@ public function createPlaceholder(array $element) { // The cacheability metadata for the placeholder. The rendered result of // the placeholder may itself be cached, if [#cache][keys] are specified. '#cache' => TRUE, - // The options for creating the placeholder. (optional) - '#create_placeholder_options' => TRUE, ]); // Generate placeholder markup. Note that the only requirement is that this diff --git a/core/lib/Drupal/Core/Render/Renderer.php b/core/lib/Drupal/Core/Render/Renderer.php index c1cbc0a..9d62dfa 100644 --- a/core/lib/Drupal/Core/Render/Renderer.php +++ b/core/lib/Drupal/Core/Render/Renderer.php @@ -325,7 +325,6 @@ protected function doRender(&$elements, $is_root_call = FALSE) { '#lazy_builder', '#cache', '#create_placeholder', - '#create_placeholder_options', // These keys are not actually supported, but they are added automatically // by the Renderer, so we don't crash on them; them being missing when // their #lazy_builder callback is invoked won't surprise the developer. diff --git a/core/modules/big_pipe/src/Render/BigPipe.php b/core/modules/big_pipe/src/Render/BigPipe.php index 6c8cb68..b85e625 100644 --- a/core/modules/big_pipe/src/Render/BigPipe.php +++ b/core/modules/big_pipe/src/Render/BigPipe.php @@ -115,13 +115,6 @@ public function sendContent($content, $attachments, array $placeholders) { $placeholders = []; } - foreach ($placeholders as $key => $placeholder) { - if ($placeholder['#create_placeholder_options']['big_pipe']['renderer'] == 'half_pipe') { - $half_pipe_placeholders[$key] = $placeholder; - unset($placeholders[$key]); - } - } - if (!empty($half_pipe_placeholders)) { $extra_attachments = $this->doHalfPipe($page_parts[0], $half_pipe_placeholders); // Print the extra attachments. diff --git a/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php b/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php index 4a01140..6701ae1 100644 --- a/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php +++ b/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php @@ -57,28 +57,23 @@ public function processPlaceholders(array $placeholders) { $token = ''; foreach ($placeholders as $placeholder => $placeholder_elements) { - // Blacklist some #lazy_builder callbacks. - // @todo Use #create_placeholder_options instead. - if (isset($placeholder_elements['#lazy_builder'][0])) { - // Route CSRF tokens, form CSRF token and form actions are (part of) - // HTML attributes, not HTML. - if ($placeholder_elements['#lazy_builder'][0] == 'route_processor_csrf:renderPlaceholderCsrfToken') { - continue; - } - elseif ($placeholder_elements['#lazy_builder'][0] == 'form_builder:renderPlaceholderFormAction') { - continue; - } - elseif ($placeholder_elements['#lazy_builder'][0] == 'form_builder:renderFormTokenPlaceholder') { - continue; - } + // BigPipe uses JavaScript and the DOM to find the placeholder to replace. + // This means finding the placeholder to replace must be efficient. Most + // placeholders are HTML, which we can find efficiently thanks to the + // querySelector API. But some placeholders are HTML attribute values or + // parts thereof, and potentially even plain text in DOM text nodes. For + // BigPipe's JavaScript to find those placeholders, it would need to + // iterate over all DOM text nodes. This is highly inefficient. Therefore, + // the BigPipe placeholder strategy only converts HTML placeholders into + // BigPipe placeholders. The other placeholders need to be replaced on the + // server, not via BigPipe. + // @see \Drupal\Core\Access\RouteProcessorCsrf::renderPlaceholderCsrfToken() + // @see \Drupal\Core\Form\FormBuilder::renderFormTokenPlaceholder() + // @see \Drupal\Core\Form\FormBuilder::renderPlaceholderFormAction() + if ($placeholder[0] !== '<' || $placeholder !== Html::normalize($placeholder)) { + continue; } - $placeholder_elements += [ '#create_placeholder_options' => []]; - $placeholder_elements['#create_placeholder_options'] += [ 'big_pipe' => []]; - $placeholder_elements['#create_placeholder_options']['big_pipe'] += [ - 'renderer' => 'big_pipe', - ]; - $html_placeholder = Html::getId($placeholder . '-' . $token); $return[$placeholder] = [ '#markup' => '
',