From c03da18a4d4c350b2cb143d3b63f744eb55803a5 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Thu, 12 Dec 2024 14:47:40 -0800 Subject: [PATCH 1/2] Don't let manifesto mutate the manifest json. --- src/state/selectors/manifests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/state/selectors/manifests.js b/src/state/selectors/manifests.js index 98e312d47..e0ea6054e 100644 --- a/src/state/selectors/manifests.js +++ b/src/state/selectors/manifests.js @@ -10,7 +10,7 @@ import { getConfig } from './config'; /** */ function createManifestoInstance(json, locale) { if (!json) return undefined; - const manifestoObject = Utils.parseManifest(json, locale ? { locale } : undefined); + const manifestoObject = Utils.parseManifest(JSON.parse(JSON.stringify(json)), locale ? { locale } : undefined); // Local patching of Manifesto so that when its a Collection, it behaves similarly if (typeof manifestoObject.getSequences != 'function') { manifestoObject.getSequences = () => []; From 659155984169a61385849ff6c0d50a9f9f922584 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Thu, 12 Dec 2024 16:17:36 -0800 Subject: [PATCH 2/2] Add a comment --- src/state/selectors/manifests.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/state/selectors/manifests.js b/src/state/selectors/manifests.js index e0ea6054e..8c99dc926 100644 --- a/src/state/selectors/manifests.js +++ b/src/state/selectors/manifests.js @@ -10,6 +10,7 @@ import { getConfig } from './config'; /** */ function createManifestoInstance(json, locale) { if (!json) return undefined; + // Use JSON stringify/parse to create a deep copy and prevent Manifesto from mutating the json const manifestoObject = Utils.parseManifest(JSON.parse(JSON.stringify(json)), locale ? { locale } : undefined); // Local patching of Manifesto so that when its a Collection, it behaves similarly if (typeof manifestoObject.getSequences != 'function') {