From 5faf81e9a5e9ac0f89fa218e4f857b0bcbd12bd3 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Sat, 6 Dec 2014 09:28:46 -0800 Subject: [PATCH] [Layout] Handle mutation edge case Fix an edge case in the mutation capability where model data could be lost during a mutation; this supports auto-mutate/persist functionality for representations, which allows Layout editing (transitioned for WTD-535) to be persisted thereby. --- platform/core/src/capabilities/MutationCapability.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platform/core/src/capabilities/MutationCapability.js b/platform/core/src/capabilities/MutationCapability.js index 58fed4a343..d0d6c2b360 100644 --- a/platform/core/src/capabilities/MutationCapability.js +++ b/platform/core/src/capabilities/MutationCapability.js @@ -59,7 +59,11 @@ define( // Allow mutators to change their mind by // returning false. if (mutationResult !== false) { - copyValues(model, result); + // Copy values if result was a different object + // (either our clone or some other new thing) + if (model !== result) { + copyValues(model, result); + } model.modified = Date.now(); }