File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -70,9 +70,9 @@ function createEmpty<T>(source: T) {
70
70
export function merge < T extends object > ( ...sources : T [ ] ) {
71
71
let clone = createEmpty ( sources [ 0 ] ) ;
72
72
73
- const loopSet = new Set < object > ( ) ;
74
-
75
73
sources . forEach ( src => {
74
+ const loopSet = new Set < object > ( ) ;
75
+
76
76
function internalMerge ( path : Path ) {
77
77
const value = get ( src , path ) ;
78
78
Original file line number Diff line number Diff line change @@ -192,6 +192,24 @@ describe('utils', () => {
192
192
selector : [ 'K1' , 'K2' ] ,
193
193
} ) ;
194
194
} ) ;
195
+
196
+ it ( 'shallow copy' , ( ) => {
197
+ const ori = {
198
+ list : [ { a : 1 } , { a : 2 } ] ,
199
+ } ;
200
+
201
+ const cloneList = [ ...ori . list ] ;
202
+ cloneList [ 0 ] = {
203
+ ...cloneList [ 0 ] ,
204
+ b : 3 ,
205
+ } ;
206
+
207
+ const merged = merge ( ori , { list : cloneList } ) ;
208
+
209
+ expect ( merged ) . toEqual ( {
210
+ list : [ { a : 1 , b : 3 } , { a : 2 } ] ,
211
+ } ) ;
212
+ } ) ;
195
213
} ) ;
196
214
} ) ;
197
215
You can’t perform that action at this time.
0 commit comments