From ad279149ea47079d172a5057a3539e3d89f1b71b Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 18 Apr 2017 12:22:56 +0530 Subject: [PATCH] [fix] frappe/erpnext#8463 --- frappe/public/js/frappe/dom.js | 10 +++++++++- frappe/public/js/frappe/form/control.js | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/dom.js b/frappe/public/js/frappe/dom.js index e3d48e5c5b..4ee6447a9a 100644 --- a/frappe/public/js/frappe/dom.js +++ b/frappe/public/js/frappe/dom.js @@ -30,10 +30,12 @@ frappe.dom = { remove_script_and_style: function(txt) { var div = document.createElement('div'); div.innerHTML = txt; + var found = false; ["script", "style", "noscript", "title", "meta", "base", "head"].forEach(function(e, i) { var elements = div.getElementsByTagName(e); var i = elements.length; while (i--) { + found = true; elements[i].parentNode.removeChild(elements[i]); } }); @@ -43,10 +45,16 @@ frappe.dom = { var i = elements.length; while (i--) { if (elements[i].getAttribute("rel")=="stylesheet"){ + found = true; elements[i].parentNode.removeChild(elements[i]); } } - return div.innerHTML; + if(found) { + return div.innerHTML; + } else { + // don't disturb + return txt; + } }, is_element_in_viewport: function (el) { diff --git a/frappe/public/js/frappe/form/control.js b/frappe/public/js/frappe/form/control.js index 21d3f3afe6..91a860077a 100755 --- a/frappe/public/js/frappe/form/control.js +++ b/frappe/public/js/frappe/form/control.js @@ -1758,8 +1758,9 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({ set_input: function(value) { if(value == null) value = ""; value = frappe.dom.remove_script_and_style(value); - if(value !== this.get_value()) + if(value !== this.get_value()) { this.editor.summernote('code', value); + } this.last_value = value; }, set_focus: function() {