From 44108135029ac064c3c409e67d40ba5da3f251cd Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 24 May 2021 09:05:00 +0530 Subject: [PATCH] fix: Use extend_cscript in make to properly extend functions of class --- .eslintrc | 3 ++- frappe/public/js/frappe/form/script_manager.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.eslintrc b/.eslintrc index a80d2910fa..cc7f555669 100644 --- a/.eslintrc +++ b/.eslintrc @@ -149,6 +149,7 @@ "before": true, "beforeEach": true, "qz": true, - "localforage": true + "localforage": true, + "extend_cscript": true } } diff --git a/frappe/public/js/frappe/form/script_manager.js b/frappe/public/js/frappe/form/script_manager.js index 1fe1f1548e..f960f4f767 100644 --- a/frappe/public/js/frappe/form/script_manager.js +++ b/frappe/public/js/frappe/form/script_manager.js @@ -8,6 +8,7 @@ window.extend_cscript = (cscript, controller_object) => { if (cscript && controller_object) { cscript.__proto__ = controller_object.__proto__; } + return cscript; }; frappe.ui.form.get_event_handler_list = function(doctype, fieldname) { @@ -81,7 +82,7 @@ frappe.ui.form.ScriptManager = class ScriptManager { $.extend(this, opts); } make(ControllerClass) { - this.frm.cscript = $.extend(this.frm.cscript, + this.frm.cscript = extend_cscript(this.frm.cscript, new ControllerClass({frm: this.frm})); } trigger(event_name, doctype, name) {