diff --git a/core/misc/ajax.es6.js b/core/misc/ajax.es6.js
index 72da2af326..8c59d13989 100644
--- a/core/misc/ajax.es6.js
+++ b/core/misc/ajax.es6.js
@@ -988,6 +988,9 @@
* {@link Drupal.Ajax} object created by {@link Drupal.ajax}.
* @param {object} response
* The response from the Ajax request.
+ *
+ * @todo: Mark the function as deprecated after it will be possible. See
+ * https://www.drupal.org/project/drupal/issues/2973400
*/
Drupal.theme.ajaxWrapperNewContent = ($newContent, ajax, response) => (
(response.effect || ajax.effect) !== 'none' &&
@@ -1008,6 +1011,9 @@
*
* @param {jQuery} $elements
* Response elements after parsing.
+ *
+ * @todo: Mark the function as deprecated after it will be possible. See
+ * https://www.drupal.org/project/drupal/issues/2973400
*/
Drupal.theme.ajaxWrapperMultipleRootElements = ($elements) => (
$('
').append($elements)
@@ -1070,7 +1076,7 @@
// Apply any settings from the returned JSON if available.
const settings = response.settings || ajax.settings || drupalSettings;
- // Parse response.data into an element collection.
+ // Parse response.data to get element collection.
let $newContent = $('').html(response.data).contents();
$newContent = Drupal.theme('ajaxWrapperNewContent', $newContent, ajax, response);
diff --git a/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php b/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
index eccc259874..68c85ad3d9 100644
--- a/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
+++ b/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
@@ -327,25 +327,33 @@ public function dialogClose() {
* Render types.
*/
protected function getRenderTypes() {
- $render_types = [
+ $render_single_root = [
'pre-wrapped-div' => '
',
- 'svg' => '',
- 'empty' => '',
];
- foreach ($render_types as $key => $render) {
+
+ $render_info = [];
+ foreach ($render_single_root as $key => $render) {
$render_info[$key] = ['render' => $render, 'effect' => 'fade'];
- $render_info["$key--effect-none"] = ['render' => $render, 'effect' => 'none'];
}
+ foreach ($render_multiple_root as $key => $render) {
+ $render_info[$key] = ['render' => $render, 'effect' => 'none'];
+ $render_info["$key--effect"] = ['render' => $render, 'effect' => 'fade'];
+ }
+
return $render_info;
}
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php
index 16b6e11aa2..80bddca2b7 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php
@@ -12,6 +12,9 @@
*/
class AjaxTest extends JavascriptTestBase {
+ /**
+ * {@inheritdoc}
+ */
protected $minkDefaultDriverClass = DrupalSelenium2Driver::class;
/**
@@ -93,67 +96,40 @@ public function testDrupalSettingsCachingRegression() {
* part of the context.
*/
public function testInsertAjaxResponse() {
- // Test that no additional wrapper is added when inserting already wrapped
- // response data and all top-level node elements (context) are processed
- // correctly.
- $test_cases['pre-wrapped-div'] = '
pre-wrapped
';
- $test_cases['pre-wrapped-span'] = 'pre-wrapped';
- // Test that no additional empty leading div is added when the return
- // value had a leading space and all top-level node elements (context) are
- // processed correctly.
- $test_cases['pre-wrapped-whitespace'] = "
pre-wrapped-whitespace
\n";
- // Test that not wrapped response data (text node) is inserted not wrapped
- // and all top-level node elements (context) are processed correctly.
- $test_cases['not-wrapped'] = 'not-wrapped';
- // Test that not wrapped response data (text node and comment node) is
- // inserted wrapped and all top-level node elements
- // (context) are processed correctly.
- $test_cases['comment-string-not-wrapped'] = 'comment-string-not-wrapped';
- // Test that top-level comments (which are not lead by text nodes) are
- // inserted without wrapper.
- $test_cases['comment-not-wrapped'] = '
comment-not-wrapped
';
- // Test that mixed inline & block level elements and comments response data
- // is inserted correctly.
- $test_cases['mixed'] = ' foo foo bar
some string
additional not wrapped strings,
final string
';
- // Test that when the response has only top-level node elements, they
- // are processed properly without extra wrapping.
- $test_cases['top-level-only'] = '
element #1
element #2
';
- // Test that whitespaces at start or end don't wrap the response when
- // there are multiple top-level nodes.
- $test_cases['top-level-only-pre-whitespace'] = '
element #1
element #2
';
- // Test when there are whitespaces between top-level divs.
- $test_cases['top-level-only-middle-whitespace-div'] = '
element #1
element #2
';
- // Test when there are whitespaces between top-level spans.
- $test_cases['top-level-only-middle-whitespace-span'] = 'element #1element #2';
- // Test that svg parsed correctly.
- $test_cases['svg'] = '';
- // Test that empty response data.
- $test_cases['empty'] = '';
-
- foreach ($test_cases as $key => $render) {
- $test_all_cases["$key--effect-none"] = $render;
- }
- $test_cases += $test_all_cases;
-
- $multiple_root_cases = [
- 'mixed',
- 'top-level-only',
- 'top-level-only-pre-whitespace',
- 'top-level-only-middle-whitespace-div',
- 'top-level-only-middle-whitespace-span',
+ $render_single_root = [
+ 'pre-wrapped-div' => '