File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
packages/angular_devkit/core/src/utils Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ export function deepCopy<T extends any>(value: T): T {
40
40
return JSON . parse ( valueCasted [ 'toJSON' ] ( ) ) ;
41
41
}
42
42
43
- const copy = new ( Object . getPrototypeOf ( valueCasted ) . constructor ) ( ) ;
43
+ const copy = Object . create ( Object . getPrototypeOf ( valueCasted ) ) ;
44
44
valueCasted [ copySymbol ] = copy ;
45
45
for ( const key of Object . getOwnPropertyNames ( valueCasted ) ) {
46
46
copy [ key ] = deepCopy ( valueCasted [ key ] ) ;
Original file line number Diff line number Diff line change @@ -50,5 +50,11 @@ describe('object', () => {
50
50
expect ( result . b ) . not . toBe ( data1 ) ;
51
51
expect ( result . b ) . toBe ( result . b . circular . b ) ;
52
52
} ) ;
53
+
54
+ it ( 'works with null prototype' , ( ) => {
55
+ const data = Object . create ( null ) ;
56
+ data [ 'a' ] = 1 ;
57
+ expect ( deepCopy ( data ) ) . toEqual ( data ) ;
58
+ } ) ;
53
59
} ) ;
54
60
} ) ;
You can’t perform that action at this time.
0 commit comments