diff -u b/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php b/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
--- b/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
+++ b/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
@@ -290,6 +290,7 @@
'not-wrapped' => 'not-wrapped',
'comment-not-wrapped' => '
',
'mixed' => ' foo foo bar additional not wrapped strings, final string
',
+ 'top-level-only' => 'element #1
element #2
',
'inline' => 'inline BLOCK LEVEL
',
'empty' => '',
];
diff -u b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php
--- b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php
@@ -138,6 +138,13 @@
'render_type' => 'mixed',
'expected' => 'foo foo bar
additional not wrapped strings,
final string
',
],
+ // Test that when the response has only top-level node elements, they
+ // are processed properly without extra wrapping.
+ [
+ 'method' => 'html',
+ 'render_type' => 'top-level-only',
+ 'expected' => 'element #1
element #2
',
+ ],
// Test that inline response data.
[
'render_type' => 'inline',