Use the clone helper instead of a interal function

This commit is contained in:
2025-02-06 22:26:19 +01:00
parent a821354288
commit 727f3ecf11
3 changed files with 127 additions and 23 deletions

View File

@ -5,6 +5,7 @@ This program is available under Apache License Version 2.0
*/
import { LitElement, html, css } from 'lit';
import { clone } from '@tp/helpers/clone.js';
class TpForm extends LitElement {
static get styles() {
@ -373,27 +374,7 @@ class TpForm extends LitElement {
value = control.defaultValue || control.getAttribute('default-value');
}
let copy;
switch (typeof value) {
case 'string':
case 'number':
case 'boolean':
copy = value;
break;
case 'object':
if (Array.isArray(value)) {
copy = value.slice(0);
} else if (value === null) {
copy = null;
} else if (value instanceof Date) {
copy = new Date(value.getTime());
} else {
copy = Object.assign({}, value);
}
break;
}
return copy;
return clone(value);
}
_readonlyChanged() {