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 {
4040 return JSON . parse ( valueCasted [ 'toJSON' ] ( ) ) ;
4141 }
4242
43- const copy = new ( Object . getPrototypeOf ( valueCasted ) . constructor ) ( ) ;
43+ const copy = Object . create ( Object . getPrototypeOf ( valueCasted ) ) ;
4444 valueCasted [ copySymbol ] = copy ;
4545 for ( const key of Object . getOwnPropertyNames ( valueCasted ) ) {
4646 copy [ key ] = deepCopy ( valueCasted [ key ] ) ;
Original file line number Diff line number Diff line change @@ -50,5 +50,11 @@ describe('object', () => {
5050 expect ( result . b ) . not . toBe ( data1 ) ;
5151 expect ( result . b ) . toBe ( result . b . circular . b ) ;
5252 } ) ;
53+
54+ it ( 'works with null prototype' , ( ) => {
55+ const data = Object . create ( null ) ;
56+ data [ 'a' ] = 1 ;
57+ expect ( deepCopy ( data ) ) . toEqual ( data ) ;
58+ } ) ;
5359 } ) ;
5460} ) ;
You can’t perform that action at this time.
0 commit comments