Skip to content

Commit a72f483

Browse files
committed
Breaking: Convert Object.assign to spread operator
This ends support for Node 6
1 parent 9ce9594 commit a72f483

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/constructors/wp-request.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,10 @@ WPRequest.prototype.setHeaders = function( headers, value ) {
683683
headers = keyValToObj( headers, value );
684684
}
685685

686-
this._options.headers = Object.assign( {}, this._options.headers || {}, headers );
686+
this._options.headers = {
687+
...( this._options.headers || {} ),
688+
...headers,
689+
};
687690

688691
return this;
689692
};

tests/unit/wpapi.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -588,12 +588,16 @@ describe( 'WPAPI', () => {
588588
} );
589589

590590
it( 'does not impact or overwrite unspecified transport methods', () => {
591-
const originalMethods = Object.assign( {}, site._options.transport );
591+
const originalMethods = {
592+
...site._options.transport,
593+
};
592594
site.transport( {
593595
get() {},
594596
put() {},
595597
} );
596-
const newMethods = Object.assign( {}, site._options.transport );
598+
const newMethods = {
599+
...site._options.transport,
600+
};
597601
expect( newMethods.delete ).toBe( originalMethods.delete );
598602
expect( newMethods.post ).toBe( originalMethods.post );
599603

0 commit comments

Comments
 (0)