From df92c33534d09dc45df13496c6fca58f8abb8d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Guti=C3=A9rrez?= Date: Fri, 14 Aug 2020 17:15:16 -0500 Subject: [PATCH] Avoid removing all scripts --- livepreview/static/livepreview/js/livepreview_fe.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/livepreview/static/livepreview/js/livepreview_fe.js b/livepreview/static/livepreview/js/livepreview_fe.js index 58cef2f..ed83687 100644 --- a/livepreview/static/livepreview/js/livepreview_fe.js +++ b/livepreview/static/livepreview/js/livepreview_fe.js @@ -4,7 +4,7 @@ $(document).ready(function() { function stripScripts(s) { var div = document.createElement('div'); div.innerHTML = s; - var scripts = div.getElementsByTagName('script'); + var scripts = div.querySelectorAll('.js-livepreview-script script'); var i = scripts.length; while (i--) { scripts[i].parentNode.removeChild(scripts[i]); @@ -38,10 +38,6 @@ $(document).ready(function() { success: function (data, textStatus, jqXHR) { if(window.currentDom !== data) { window.currentDom = data - // Select the entire BODY - var $body = $("body") - // Remove everything EXCEPT