1
0
Fork 0

feat(core): When injecting a part, copy store[part.name]

This commit is contained in:
joostdecock 2023-09-05 11:04:44 +02:00
parent badd0609b1
commit ca5556ef8c

View file

@ -302,7 +302,7 @@ Part.prototype.__getIdClosure = function () {
/** /**
* Copies point/path/snippet data from part orig into this * Copies point/path/snippet data from part orig into this
* Also sets the freeId * Also sets the freeId, and copied store.parts[name] data
* *
* @private * @private
* @param {object} orig - The original part to inject into this * @param {object} orig - The original part to inject into this
@ -337,6 +337,14 @@ Part.prototype.__inject = function (orig) {
for (let i in orig.snippets) { for (let i in orig.snippets) {
this.snippets[i] = orig.snippets[i].clone() this.snippets[i] = orig.snippets[i].clone()
} }
/*
* This only supports what can be serialized
*/
if (orig.context.store.parts?.[orig.name]) {
this.context.store.parts[this.name] = JSON.parse(
JSON.stringify(orig.context.store.parts[orig.name])
)
}
return this return this
} }