diff -u b/core/misc/ajax.js b/core/misc/ajax.js --- b/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -1031,7 +1031,7 @@ // context object that includes top-level text nodes. Therefore text nodes // will be wrapped with a element. This also gives themers the // possibility to style the response. - var $new_content; + var $newContent; var onlyElementNodes; var trimedData = response.data.trim(); @@ -1049,20 +1049,21 @@ }); } - // If only NODE_ELEMENT or COMMENT_NODE elements are returned skip wrap processing. + // If only NODE_ELEMENT or COMMENT_NODE elements are returned + // skip wrap processing. if (!onlyElementNodes) { // If response.data contains only one TEXT_ELEMENT if the target element // is not styled as a block, response.data will be wrapped with SPAN. if (responseDataNodes.length === 1 || ($wrapper.css('display') !== 'block')) { - $new_content = $(''); + $newContent = $(''); } else { - $new_content = $('
'); + $newContent = $('
'); } - $new_content.html(responseDataNodes); + $newContent.html(responseDataNodes); } else { - $new_content = $(responseDataNodes); + $newContent = $(responseDataNodes); } // If removing content from the wrapper, detach behaviors first. @@ -1077,32 +1078,32 @@ } // Add the new content to the page. - $wrapper[method]($new_content); + $wrapper[method]($newContent); // Immediately hide the new content if we're using any effects. if (effect.showEffect !== 'show') { - $new_content.hide(); + $newContent.hide(); } // Determine which effect to use and what content will receive the // effect, then show the new content. - if ($new_content.find('.ajax-new-content').length > 0) { - $new_content.find('.ajax-new-content').hide(); - $new_content.show(); - $new_content.find('.ajax-new-content')[effect.showEffect](effect.showSpeed); + if ($newContent.find('.ajax-new-content').length > 0) { + $newContent.find('.ajax-new-content').hide(); + $newContent.show(); + $newContent.find('.ajax-new-content')[effect.showEffect](effect.showSpeed); } else if (effect.showEffect !== 'show') { - $new_content[effect.showEffect](effect.showSpeed); + $newContent[effect.showEffect](effect.showSpeed); } // Attach all JavaScript behaviors to the new content, if it was // successfully added to the page, this if statement allows // `#ajax['wrapper']` to be optional. - if ($new_content.parents('html').length > 0) { + if ($newContent.parents('html').length > 0) { // Apply any settings from the returned JSON if available. settings = response.settings || ajax.settings || drupalSettings; // Attach behaviors to all element nodes. - $new_content.each(function () { + $newContent.each(function () { if (this.nodeType === Node.ELEMENT_NODE) { Drupal.attachBehaviors(this, settings); } diff -u b/core/modules/system/tests/modules/ajax_test/js/insert-ajax.js b/core/modules/system/tests/modules/ajax_test/js/insert-ajax.js --- b/core/modules/system/tests/modules/ajax_test/js/insert-ajax.js +++ b/core/modules/system/tests/modules/ajax_test/js/insert-ajax.js @@ -1,6 +1,7 @@ /** * @file - * Provides method to test ajax requests. + * Drupal behavior to attach click event handlers to ajax-insert and + * ajax-insert-inline links for testing ajax requests. */ (function ($, window, Drupal, drupalSettings) { diff -u b/core/misc/ajax.js b/core/misc/ajax.js --- b/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -1031,7 +1031,7 @@ // context object that includes top-level text nodes. Therefore text nodes // will be wrapped with a element. This also gives themers the // possibility to style the response. - var $new_content; + var $newContent; var onlyElementNodes; var trimedData = response.data.trim(); @@ -1049,20 +1049,21 @@ }); } - // If only NODE_ELEMENT or COMMENT_NODE elements are returned skip wrap processing. + // If only NODE_ELEMENT or COMMENT_NODE elements are returned + // skip wrap processing. if (!onlyElementNodes) { // If response.data contains only one TEXT_ELEMENT if the target element // is not styled as a block, response.data will be wrapped with SPAN. if (responseDataNodes.length === 1 || ($wrapper.css('display') !== 'block')) { - $new_content = $(''); + $newContent = $(''); } else { - $new_content = $('
'); + $newContent = $('
'); } - $new_content.html(responseDataNodes); + $newContent.html(responseDataNodes); } else { - $new_content = $(responseDataNodes); + $newContent = $(responseDataNodes); } // If removing content from the wrapper, detach behaviors first. @@ -1077,32 +1078,32 @@ } // Add the new content to the page. - $wrapper[method]($new_content); + $wrapper[method]($newContent); // Immediately hide the new content if we're using any effects. if (effect.showEffect !== 'show') { - $new_content.hide(); + $newContent.hide(); } // Determine which effect to use and what content will receive the // effect, then show the new content. - if ($new_content.find('.ajax-new-content').length > 0) { - $new_content.find('.ajax-new-content').hide(); - $new_content.show(); - $new_content.find('.ajax-new-content')[effect.showEffect](effect.showSpeed); + if ($newContent.find('.ajax-new-content').length > 0) { + $newContent.find('.ajax-new-content').hide(); + $newContent.show(); + $newContent.find('.ajax-new-content')[effect.showEffect](effect.showSpeed); } else if (effect.showEffect !== 'show') { - $new_content[effect.showEffect](effect.showSpeed); + $newContent[effect.showEffect](effect.showSpeed); } // Attach all JavaScript behaviors to the new content, if it was // successfully added to the page, this if statement allows // `#ajax['wrapper']` to be optional. - if ($new_content.parents('html').length > 0) { + if ($newContent.parents('html').length > 0) { // Apply any settings from the returned JSON if available. settings = response.settings || ajax.settings || drupalSettings; // Attach behaviors to all element nodes. - $new_content.each(function () { + $newContent.each(function () { if (this.nodeType === Node.ELEMENT_NODE) { Drupal.attachBehaviors(this, settings); } diff -u b/core/modules/system/tests/modules/ajax_test/js/insert-ajax.js b/core/modules/system/tests/modules/ajax_test/js/insert-ajax.js --- b/core/modules/system/tests/modules/ajax_test/js/insert-ajax.js +++ b/core/modules/system/tests/modules/ajax_test/js/insert-ajax.js @@ -1,6 +1,7 @@ /** * @file - * Provides method to test ajax requests. + * Drupal behavior to attach click event handlers to ajax-insert and + * ajax-insert-inline links for testing ajax requests. */ (function ($, window, Drupal, drupalSettings) { 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 @@ -155,7 +155,7 @@ $this->clickLink("Link html {$test_case['render_type']}"); $assert->assertWaitOnAjaxRequest(); // Extra span added by a second prepend command on the ajax requests. - $assert->responseContains($this->wrapAjaxTarget('' . $test_case['expected'])); + $assert->responseContains($this->wrapAjaxTarget($test_case['expected'])); } foreach ($test_cases as $test_case) {