From 6170b408fdeed35b9c6f3935b04df9add9cd7221 Mon Sep 17 00:00:00 2001 From: Luke Deniston Date: Tue, 14 Jan 2020 15:02:19 -0800 Subject: [PATCH] Fixes changesets for ember data models with more than one attribute. --- addon/utils/merge-deep.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addon/utils/merge-deep.ts b/addon/utils/merge-deep.ts index 3d697975..a079c63b 100644 --- a/addon/utils/merge-deep.ts +++ b/addon/utils/merge-deep.ts @@ -41,6 +41,11 @@ function propertyIsOnObject(object: any, property: any) { // Protects from prototype poisoning and unexpected merging up the prototype chain. function propertyIsUnsafe(target: any, key: string): Boolean { + // Special case for ember data model attributes. + if(target.constructor && target.constructor.attributes && target.constructor.attributes.has(key)) { + return false; + } + return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet, && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain, && Object.propertyIsEnumerable.call(target, key)); // and also unsafe if they're nonenumerable.