mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-04-06 17:31:09 +08:00
Property object clone support
This commit is contained in:
parent
f222332772
commit
12a5b9d294
@ -76,7 +76,7 @@ export class Property {
|
||||
} else if (this.isArray) {
|
||||
return this.default ? this.default.slice() : [];
|
||||
} else if (this.isObject) {
|
||||
return Object.keys(this.default).length ? JSON.parse(JSON.stringify(this.default)) : {};
|
||||
return Object.keys(this.default).length ? structuredClone(this.default) : {};
|
||||
} else {
|
||||
return this.default;
|
||||
}
|
||||
@ -99,7 +99,7 @@ export class Property {
|
||||
else if (this.isBoolean) {
|
||||
Merge.boolean(instance, data, this.name, this.merge_validation)
|
||||
}
|
||||
else if (this.isArray || this.isVector || this.isVector2) {
|
||||
else if (this.isArray || this.isVector) {
|
||||
if (data[this.name] instanceof Array) {
|
||||
if (instance[this.name] instanceof Array == false) {
|
||||
instance[this.name] = [];
|
||||
@ -107,6 +107,11 @@ export class Property {
|
||||
instance[this.name].replace(data[this.name]);
|
||||
}
|
||||
}
|
||||
else if (this.isObject) {
|
||||
if (typeof data[this.name] == 'object') {
|
||||
instance[this.name] = structuredClone(data[this.name]);
|
||||
}
|
||||
}
|
||||
else if (this.isInstance) {
|
||||
if (typeof data[this.name] === 'object') {
|
||||
instance[this.name] =data[this.name];
|
||||
@ -131,6 +136,10 @@ export class Property {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (this.isObject) {
|
||||
if (typeof instance[this.name] == 'object') {
|
||||
target[this.name] = structuredClone(instance[this.name]);
|
||||
}
|
||||
} else {
|
||||
target[this.name] = instance[this.name];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user