Verified Commit b4a02610 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3238870 by shubh_, mstrelan, nod_, hooroomoo, kostyashupenko,...

Issue #3238870 by shubh_, mstrelan, nod_, hooroomoo, kostyashupenko, smustgrave, larowlan, thebumik, lauriii: Refactor (if feasible) use of jquery parseHTML function to use vanillaJS
parent bd12c418
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@
    "jquery/no-param": 2,
    "jquery/no-parent": 0,
    "jquery/no-parents": 0,
    "jquery/no-parse-html": 0,
    "jquery/no-parse-html": 2,
    "jquery/no-prop": 0,
    "jquery/no-proxy": 2,
    "jquery/no-ready": 2,
+14 −1
Original line number Diff line number Diff line
@@ -1333,7 +1333,20 @@
      const settings = response.settings || ajax.settings || drupalSettings;

      // Parse response.data into an element collection.
      let $newContent = $($.parseHTML(response.data, document, true));
      const parseHTML = (htmlString) => {
        const fragment = document.createDocumentFragment();
        // Create a temporary div element
        const tempDiv = fragment.appendChild(document.createElement('div'));

        // Set the innerHTML of the div to the provided HTML string
        tempDiv.innerHTML = htmlString;

        // Return the contents of the temporary div
        return tempDiv.childNodes;
      };

      let $newContent = $(parseHTML(response.data));

      // For backward compatibility, in some cases a wrapper will be added. This
      // behavior will be removed before Drupal 9.0.0. If different behavior is
      // needed, the theme functions can be overridden.