From a027649ae58078347e8b2a15419e0c147b677e24 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 15 Dec 2021 11:49:18 -0700 Subject: [PATCH] Fix the failing clone() --- api/js/etemplate/Et2Widget/Et2Widget.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/api/js/etemplate/Et2Widget/Et2Widget.ts b/api/js/etemplate/Et2Widget/Et2Widget.ts index 2a9145c85f..366c4f9a18 100644 --- a/api/js/etemplate/Et2Widget/Et2Widget.ts +++ b/api/js/etemplate/Et2Widget/Et2Widget.ts @@ -289,7 +289,7 @@ const Et2WidgetMixin = (superClass) => { let oldValue = this._widget_id; this._widget_id = value; - this.setAttribute("id", this._widget_id ? this.getInstanceManager().uniqueId + '_' + this._widget_id.replace(/\./g, '-') : ""); + this.setAttribute("id", this._widget_id ? this.getInstanceManager()?.uniqueId + '_' + this._widget_id.replace(/\./g, '-') : ""); this.requestUpdate("id", oldValue); } @@ -828,13 +828,6 @@ const Et2WidgetMixin = (superClass) => // Create the copy var copy = this.cloneNode(); - let widget_class = window.customElements.get(this.localName); - let properties = widget_class ? widget_class.properties : []; - for(let key in properties) - { - copy[key] = this[key]; - } - if(_parent) { copy.setParent(_parent); @@ -848,6 +841,13 @@ const Et2WidgetMixin = (superClass) => copy.setInstanceManager(this.getInstanceManager()); } + let widget_class = window.customElements.get(this.localName); + let properties = widget_class ? widget_class.properties : []; + for(let key in properties) + { + copy[key] = this[key]; + } + // Create a clone of all child widgets of the given object for(var i = 0; i < this.getChildren().length; i++) {