force reconfigure if called by user

This commit is contained in:
jrkb 2023-08-04 13:01:16 +02:00
parent 938568037a
commit 7b39d4feaa

View file

@ -166,13 +166,12 @@ export default class TheatreSheet implements ISheet {
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
const prevConfig = weakMapOfUnsanitizedProps.get(existingObject) const prevConfig = weakMapOfUnsanitizedProps.get(existingObject)
if (prevConfig) { if (prevConfig) {
if (!deepEqual(config, prevConfig)) {
if (opts?.reconfigure === true) { if (opts?.reconfigure === true) {
const sanitizedConfig = compound(config) const sanitizedConfig = compound(config)
existingObject.template.reconfigure(sanitizedConfig) existingObject.template.reconfigure(sanitizedConfig)
weakMapOfUnsanitizedProps.set(existingObject, config) weakMapOfUnsanitizedProps.set(existingObject, config)
return existingObject.publicApi as $IntentionalAny return existingObject.publicApi as $IntentionalAny
} else { } else if (!deepEqual(config, prevConfig)) {
throw new Error( throw new Error(
`You seem to have called sheet.object("${key}", config) twice, with different values for \`config\`. ` + `You seem to have called sheet.object("${key}", config) twice, with different values for \`config\`. ` +
`This is disallowed because changing the config of an object on the fly would make it difficult to reason about.\n\n` + `This is disallowed because changing the config of an object on the fly would make it difficult to reason about.\n\n` +
@ -182,7 +181,6 @@ export default class TheatreSheet implements ISheet {
} }
} }
} }
}
if (actions) { if (actions) {
existingObject.template._temp_setActions(actions) existingObject.template._temp_setActions(actions)