diff --git a/core/misc/ajax.es6.js b/core/misc/ajax.es6.js index 418926004a..628ad427d6 100644 --- a/core/misc/ajax.es6.js +++ b/core/misc/ajax.es6.js @@ -1036,24 +1036,8 @@ // Apply any settings from the returned JSON if available. const settings = response.settings || ajax.settings || drupalSettings; - // Store SVG elements - const svgStorage = {}; - // Parse response.data into an element collection. - const $newContent = $($.parseHTML(response.data, true).map((element) => { - // If the response contains an SVG, replace it with a placeholder. - if (element.nodeName && element.nodeName === 'svg') { - // Create an ID to reference later. - const hash = `svg-${Math.random().toString(36).substring(7)}`; - svgStorage[hash] = element.outerHTML; - - // Create a plceholder DIV that will be replaced with the SVG. - const svgPlaceHolder = document.createElement('div'); - svgPlaceHolder.id = hash; - return svgPlaceHolder; - } - return element; - })); + const $newContent = $($.parseHTML(response.data, true)); // If removing content from the wrapper, detach behaviors first. switch (method) { @@ -1071,14 +1055,6 @@ // Add the new content to the page. $wrapper[method]($newContent); - // If there is any SVG data, start replacing them. - if (Object.keys(svgStorage).length) { - Object.keys(svgStorage).forEach((key) => { - // Replace each placeholder DIV with the saved SVG data. - $(`#${key}`).replaceWith(svgStorage[key]); - }); - } - // Immediately hide the new content if we're using any effects. if (effect.showEffect !== 'show') { $newContent.hide(); diff --git a/core/misc/ajax.js b/core/misc/ajax.js index 7977ee5d31..062fb10b59 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -487,19 +487,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr var settings = response.settings || ajax.settings || drupalSettings; - var svgStorage = {}; - - var $newContent = $($.parseHTML(response.data, true).map(function (element) { - if (element.nodeName && element.nodeName === 'svg') { - var hash = 'svg-' + Math.random().toString(36).substring(7); - svgStorage[hash] = element.outerHTML; - - var svgPlaceHolder = document.createElement('div'); - svgPlaceHolder.id = hash; - return svgPlaceHolder; - } - return element; - })); + var $newContent = $($.parseHTML(response.data, true)); switch (method) { case 'html': @@ -515,12 +503,6 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr $wrapper[method]($newContent); - if (Object.keys(svgStorage).length) { - Object.keys(svgStorage).forEach(function (key) { - $('#' + key).replaceWith(svgStorage[key]); - }); - } - if (effect.showEffect !== 'show') { $newContent.hide(); } @@ -614,4 +596,4 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr } } }; -})(jQuery, window, Drupal, drupalSettings); \ No newline at end of file +})(jQuery, window, Drupal, drupalSettings); diff --git a/core/modules/system/tests/modules/ajax_test/js/insert-ajax.es6.js b/core/modules/system/tests/modules/ajax_test/js/insert-ajax.es6.js deleted file mode 100644 index e7fb3f212b..0000000000 --- a/core/modules/system/tests/modules/ajax_test/js/insert-ajax.es6.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @file - * Drupal behavior to attach click event handlers to ajax-insert and - * ajax-insert-inline links for testing ajax requests. - */ - -(function ($, window, Drupal) { - Drupal.behaviors.insertTest = { - attach(context) { - $('.ajax-insert').once('ajax-insert').on('click', (event) => { - event.preventDefault(); - const ajaxSettings = { - url: event.currentTarget.getAttribute('href'), - wrapper: 'ajax-target', - base: false, - element: false, - method: event.currentTarget.getAttribute('data-method'), - }; - const myAjaxObject = Drupal.ajax(ajaxSettings); - myAjaxObject.execute(); - }); - - $('.ajax-insert-inline').once('ajax-insert').on('click', (event) => { - event.preventDefault(); - const ajaxSettings = { - url: event.currentTarget.getAttribute('href'), - wrapper: 'ajax-target-inline', - base: false, - element: false, - method: event.currentTarget.getAttribute('data-method'), - }; - const myAjaxObject = Drupal.ajax(ajaxSettings); - myAjaxObject.execute(); - }); - - $(context).addClass('processed'); - }, - }; -}(jQuery, window, Drupal)); diff --git a/core/modules/system/tests/modules/ajax_test/js/insert-ajax.js b/core/modules/system/tests/modules/ajax_test/js/insert-ajax.js deleted file mode 100644 index c261bca80a..0000000000 --- a/core/modules/system/tests/modules/ajax_test/js/insert-ajax.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* DO NOT EDIT THIS FILE. -* See the following change record for more information, -* https://www.drupal.org/node/2815083 -* @preserve -**/ - -(function ($, window, Drupal) { - Drupal.behaviors.insertTest = { - attach: function attach(context) { - $('.ajax-insert').once('ajax-insert').on('click', function (event) { - event.preventDefault(); - var ajaxSettings = { - url: event.currentTarget.getAttribute('href'), - wrapper: 'ajax-target', - base: false, - element: false, - method: event.currentTarget.getAttribute('data-method') - }; - var myAjaxObject = Drupal.ajax(ajaxSettings); - myAjaxObject.execute(); - }); - - $('.ajax-insert-inline').once('ajax-insert').on('click', function (event) { - event.preventDefault(); - var ajaxSettings = { - url: event.currentTarget.getAttribute('href'), - wrapper: 'ajax-target-inline', - base: false, - element: false, - method: event.currentTarget.getAttribute('data-method') - }; - var myAjaxObject = Drupal.ajax(ajaxSettings); - myAjaxObject.execute(); - }); - - $(context).addClass('processed'); - } - }; -})(jQuery, window, Drupal); \ No newline at end of file diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php index 7a8895c9f6..c76f7136f5 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php @@ -73,7 +73,7 @@ public function testDrupalSettingsCachingRegression() { // Insert a fake library into the already loaded library settings. $fake_library = 'fakeLibrary/fakeLibrary'; - $session->evaluateScript("drupalSettings.ajaxPageState.libraries = drupalSettings.ajaxPageState.libraries + ',$fake_library';"); + $session->evaluateScript("drupalSettings.ajaxPageState.libraries = drupalSettings.ajaxPageState.libraries ',$fake_library';"); $libraries = $session->evaluateScript('drupalSettings.ajaxPageState.libraries'); // Test that the fake library is set. @@ -101,7 +101,7 @@ public function testDrupalSettingsCachingRegression() { $this->assertNotContains($fake_library, $libraries); } - /** +/** * Tests that various AJAX responses with DOM elements are correctly inserted. * * After inserting DOM elements, Drupal JavaScript behaviors should be