Rushabh Mehta 8 years ago
parent
commit
ad279149ea
2 changed files with 11 additions and 2 deletions
  1. +9
    -1
      frappe/public/js/frappe/dom.js
  2. +2
    -1
      frappe/public/js/frappe/form/control.js

+ 9
- 1
frappe/public/js/frappe/dom.js View File

@@ -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) {



+ 2
- 1
frappe/public/js/frappe/form/control.js View File

@@ -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() {


Loading…
Cancel
Save