Use the clone helper instead of a interal function
This commit is contained in:
23
tp-form.js
23
tp-form.js
@ -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() {
|
||||
|
Reference in New Issue
Block a user