jQuery replaceWith(responseText) started encoding quotes as " unexpectedly

37 Views Asked by At

I'm encountering an issue where the jQuery replaceWith(responseText) function modifies the attribute values of elements by replacing double quotes with ".

Original responseText:

<div id='whatsapp_icon' onclick='whatsappClick("37112345678", "")'></div>

After using replaceWith:

<div id="whatsapp_icon" onclick="whatsappClick(&quot;37112345678&quot;, &quot;&quot;)"></div>

This issue is recent, and previously the method worked as expected. Notably:

  • The issue does not appear on all systems, but on most systems.
  • I tried to disable all extensions in browsers, without result (and this behavior appeared not simultaneously, but during one or two days on completely independent systems).
  • The code hasn't been modified recently.
  • The jQuery library wasn't updated.
  • The .html() function exhibits the same behavior.

What could be causing this change in behavior?

1

There are 1 best solutions below

1
MatrixDevops On

Sometimes browser updates changes how HTML is being rendered and parsed. As you already mentioned the code hasn't been change neither the jQuery library nor the code. So a browser update might affect the way attribute values are displayed and processed.