Fix the failing clone()

This commit is contained in:
nathan 2021-12-15 11:49:18 -07:00
parent 8f81266b1d
commit a027649ae5

View File

@ -289,7 +289,7 @@ const Et2WidgetMixin = (superClass) =>
{ {
let oldValue = this._widget_id; let oldValue = this._widget_id;
this._widget_id = value; 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); this.requestUpdate("id", oldValue);
} }
@ -828,13 +828,6 @@ const Et2WidgetMixin = (superClass) =>
// Create the copy // Create the copy
var copy = <Et2WidgetClass>this.cloneNode(); var copy = <Et2WidgetClass>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) if(_parent)
{ {
copy.setParent(_parent); copy.setParent(_parent);
@ -848,6 +841,13 @@ const Et2WidgetMixin = (superClass) =>
copy.setInstanceManager(this.getInstanceManager()); 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 // Create a clone of all child widgets of the given object
for(var i = 0; i < this.getChildren().length; i++) for(var i = 0; i < this.getChildren().length; i++)
{ {