Skip to content

Commit

Permalink
fix: replace extendObject utility w/ object spread (#7372)
Browse files Browse the repository at this point in the history
  • Loading branch information
jelbourn authored Nov 20, 2017
1 parent c725249 commit ea54edb
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 100 deletions.
4 changes: 1 addition & 3 deletions src/lib/core/datetime/native-date-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
*/

import {Inject, Injectable, Optional} from '@angular/core';
import {extendObject} from '../util/object-extend';
import {DateAdapter, MAT_DATE_LOCALE} from './date-adapter';


// TODO(mmalerba): Remove when we no longer support safari 9.
/** Whether the browser supports the Intl API. */
const SUPPORTS_INTL_API = typeof Intl != 'undefined';
Expand Down Expand Up @@ -186,7 +184,7 @@ export class NativeDateAdapter extends DateAdapter<Date> {
date = new Date(Date.UTC(
date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(),
date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
displayFormat = extendObject({}, displayFormat, {timeZone: 'utc'});
displayFormat = {...displayFormat, timeZone: 'utc'};
}
let dtf = new Intl.DateTimeFormat(this.locale, displayFormat);
return this._stripDirectionalityCharacters(dtf.format(date));
Expand Down
2 changes: 0 additions & 2 deletions src/lib/core/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ export * from './placeholder/placeholder-options';
export * from './ripple/index';
export * from './selection/index';
export * from './style/index';
export * from './util/object-extend';


// TODO: don't have this
export * from './testing/month-constants';
50 changes: 0 additions & 50 deletions src/lib/core/util/object-extend.spec.ts

This file was deleted.

32 changes: 0 additions & 32 deletions src/lib/core/util/object-extend.ts

This file was deleted.

13 changes: 6 additions & 7 deletions src/lib/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
* found in the LICENSE file at https://angular.io/license
*/

import {Directionality} from '@angular/cdk/bidi';
import {ESCAPE} from '@angular/cdk/keycodes';
import {
BlockScrollStrategy,
Overlay,
OverlayRef,
OverlayConfig,
OverlayRef,
ScrollStrategy,
} from '@angular/cdk/overlay';
import {ComponentPortal, ComponentType, PortalInjector, TemplatePortal} from '@angular/cdk/portal';
import {filter} from 'rxjs/operators/filter';
import {startWith} from 'rxjs/operators/startWith';
import {Location} from '@angular/common';
import {
ComponentRef,
Expand All @@ -28,15 +27,15 @@ import {
SkipSelf,
TemplateRef,
} from '@angular/core';
import {extendObject} from '@angular/material/core';
import {Directionality} from '@angular/cdk/bidi';
import {Observable} from 'rxjs/Observable';
import {defer} from 'rxjs/observable/defer';
import {of as observableOf} from 'rxjs/observable/of';
import {filter} from 'rxjs/operators/filter';
import {startWith} from 'rxjs/operators/startWith';
import {Subject} from 'rxjs/Subject';
import {MatDialogConfig} from './dialog-config';
import {MatDialogContainer} from './dialog-container';
import {MatDialogRef} from './dialog-ref';
import {of as observableOf} from 'rxjs/observable/of';


export const MAT_DIALOG_DATA = new InjectionToken<any>('MatDialogData');
Expand Down Expand Up @@ -313,5 +312,5 @@ export class MatDialog {
* @returns The new configuration object.
*/
function _applyConfigDefaults(config?: MatDialogConfig): MatDialogConfig {
return extendObject(new MatDialogConfig(), config);
return {...new MatDialogConfig(), ...config};
}
9 changes: 4 additions & 5 deletions src/lib/snack-bar/snack-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
*/

import {LiveAnnouncer} from '@angular/cdk/a11y';
import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout';
import {Overlay, OverlayConfig, OverlayRef} from '@angular/cdk/overlay';
import {ComponentPortal, ComponentType, PortalInjector} from '@angular/cdk/portal';
import {ComponentRef, Injectable, Injector, Optional, SkipSelf} from '@angular/core';
import {extendObject} from '@angular/material/core';
import {first} from 'rxjs/operators/first';
import {takeUntil} from 'rxjs/operators/takeUntil';
import {SimpleSnackBar} from './simple-snack-bar';
import {MAT_SNACK_BAR_DATA, MatSnackBarConfig} from './snack-bar-config';
import {MatSnackBarContainer} from './snack-bar-container';
import {MatSnackBarRef} from './snack-bar-ref';
import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout';
import {takeUntil} from 'rxjs/operators/takeUntil';
import {first} from 'rxjs/operators/first';


/**
Expand Down Expand Up @@ -224,5 +223,5 @@ export class MatSnackBar {
* @returns The new configuration object with defaults applied.
*/
function _applyConfigDefaults(config?: MatSnackBarConfig): MatSnackBarConfig {
return extendObject(new MatSnackBarConfig(), config);
return {...new MatSnackBarConfig(), ...config};
}
3 changes: 2 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
["fit"],
["fdescribe"],
["xit"],
["xdescribe"]
["xdescribe"],
{"name": "Object.assign", "message": "Use the spread operator instead."}
],
// Disallows importing the whole RxJS library. Submodules can be still imported.
"import-blacklist": [true, "rxjs", "rxjs/operators"],
Expand Down

0 comments on commit ea54edb

Please sign in to comment.