File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 Logger,
1010 guidFor,
1111 isEmpty,
12- runInDebug
12+ runInDebug,
13+ canInvoke
1314} = Ember ;
1415
1516const {
@@ -137,12 +138,21 @@ export default Ember.Mixin.create({
137138 ! PRIMITIVE_TYPES . includes ( type )
138139 ) {
139140 let value = this . get ( name ) ;
140- let transform = getTransform ( this , type , _meta ) ;
141141
142- // Run the transform on the value. This should guarantee that we get
143- // a new instance.
144- value = transform . serialize ( value , attributeOptions ) ;
145- value = transform . deserialize ( value , attributeOptions ) ;
142+ if ( canInvoke ( value , 'copy' ) ) {
143+ // "value" is an Ember.Object using the Ember.Copyable API (if you use
144+ // the "Ember Data Model Fragments" addon and "value" is a fragment or
145+ // if use your own serializer where you deserialize a value to an
146+ // Ember.Object using this Ember.Copyable API)
147+ value = value . copy ( deep ) ;
148+ } else {
149+ let transform = getTransform ( this , type , _meta ) ;
150+
151+ // Run the transform on the value. This should guarantee that we get
152+ // a new instance.
153+ value = transform . serialize ( value , attributeOptions ) ;
154+ value = transform . deserialize ( value , attributeOptions ) ;
155+ }
146156
147157 attrs [ name ] = value ;
148158 } else {
You can’t perform that action at this time.
0 commit comments