From 29caaf3ea042044f55d8975a9915263ae0906453 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 21 Apr 2017 23:36:57 +0200 Subject: [PATCH] refactor: remove @output privatization (#4199) Fixes #4188. --- src/lib/button-toggle/button-toggle.ts | 14 ++++---------- src/lib/core/style/focus-origin-monitor.ts | 3 +-- src/lib/radio/radio.ts | 6 ++---- src/lib/slide-toggle/slide-toggle.ts | 5 ++--- src/lib/tabs/tab-body.ts | 6 ++---- src/lib/tabs/tab-group.ts | 17 ++++------------- 6 files changed, 15 insertions(+), 36 deletions(-) diff --git a/src/lib/button-toggle/button-toggle.ts b/src/lib/button-toggle/button-toggle.ts index d0d82bfb6593..8cacf286b24a 100644 --- a/src/lib/button-toggle/button-toggle.ts +++ b/src/lib/button-toggle/button-toggle.ts @@ -160,10 +160,7 @@ export class MdButtonToggleGroup implements AfterViewInit, ControlValueAccessor } /** Event emitted when the group's value changes. */ - @Output() get change(): Observable { - return this._change.asObservable(); - } - private _change: EventEmitter = new EventEmitter(); + @Output() change: EventEmitter = new EventEmitter(); private _updateButtonToggleNames(): void { if (this._buttonToggles) { @@ -198,7 +195,7 @@ export class MdButtonToggleGroup implements AfterViewInit, ControlValueAccessor event.source = this._selected; event.value = this._value; this._controlValueAccessorChangeFn(event.value); - this._change.emit(event); + this.change.emit(event); } /** @@ -372,10 +369,7 @@ export class MdButtonToggle implements OnInit { } /** Event emitted when the group value changes. */ - private _change: EventEmitter = new EventEmitter(); - @Output() get change(): Observable { - return this._change.asObservable(); - } + @Output() change: EventEmitter = new EventEmitter(); constructor(@Optional() toggleGroup: MdButtonToggleGroup, @Optional() toggleGroupMultiple: MdButtonToggleGroupMultiple, @@ -460,6 +454,6 @@ export class MdButtonToggle implements OnInit { let event = new MdButtonToggleChange(); event.source = this; event.value = this._value; - this._change.emit(event); + this.change.emit(event); } } diff --git a/src/lib/core/style/focus-origin-monitor.ts b/src/lib/core/style/focus-origin-monitor.ts index 7d9da7a6586c..d7cca8b61355 100644 --- a/src/lib/core/style/focus-origin-monitor.ts +++ b/src/lib/core/style/focus-origin-monitor.ts @@ -284,8 +284,7 @@ export class FocusOriginMonitor { selector: '[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]', }) export class CdkMonitorFocus implements OnDestroy { - @Output() - cdkFocusChange = new EventEmitter(); + @Output() cdkFocusChange = new EventEmitter(); constructor(private _elementRef: ElementRef, private _focusOriginMonitor: FocusOriginMonitor, renderer: Renderer) { diff --git a/src/lib/radio/radio.ts b/src/lib/radio/radio.ts index a8dab7a488a0..a325102f26c9 100644 --- a/src/lib/radio/radio.ts +++ b/src/lib/radio/radio.ts @@ -95,8 +95,7 @@ export class MdRadioGroup implements AfterContentInit, ControlValueAccessor { * Change events are only emitted when the value changes due to user interaction with * a radio button (the same behavior as ``). */ - @Output() - change: EventEmitter = new EventEmitter(); + @Output() change: EventEmitter = new EventEmitter(); /** Child radio buttons. */ @ContentChildren(forwardRef(() => MdRadioButton)) @@ -379,8 +378,7 @@ export class MdRadioButton implements OnInit, AfterViewInit, OnDestroy { * Change events are only emitted when the value changes due to user interaction with * the radio button (the same behavior as ``). */ - @Output() - change: EventEmitter = new EventEmitter(); + @Output() change: EventEmitter = new EventEmitter(); /** The parent radio group. May or may not be present. */ radioGroup: MdRadioGroup; diff --git a/src/lib/slide-toggle/slide-toggle.ts b/src/lib/slide-toggle/slide-toggle.ts index 21927436e996..6e5f8fcc3cfd 100644 --- a/src/lib/slide-toggle/slide-toggle.ts +++ b/src/lib/slide-toggle/slide-toggle.ts @@ -109,9 +109,8 @@ export class MdSlideToggle implements OnDestroy, AfterContentInit, ControlValueA get disableRipple(): boolean { return this._disableRipple; } set disableRipple(value) { this._disableRipple = coerceBooleanProperty(value); } - private _change: EventEmitter = new EventEmitter(); /** An event will be dispatched each time the slide-toggle changes its value. */ - @Output() change: Observable = this._change.asObservable(); + @Output() change: EventEmitter = new EventEmitter(); /** Returns the unique id for the visual hidden input. */ get inputId(): string { return `${this.id || this._uniqueId}-input`; } @@ -262,7 +261,7 @@ export class MdSlideToggle implements OnDestroy, AfterContentInit, ControlValueA let event = new MdSlideToggleChange(); event.source = this; event.checked = this.checked; - this._change.emit(event); + this.change.emit(event); } diff --git a/src/lib/tabs/tab-body.ts b/src/lib/tabs/tab-body.ts index f3d3682f2cd2..78daac792432 100644 --- a/src/lib/tabs/tab-body.ts +++ b/src/lib/tabs/tab-body.ts @@ -78,12 +78,10 @@ export class MdTabBody implements OnInit, AfterViewChecked { @ViewChild(PortalHostDirective) _portalHost: PortalHostDirective; /** Event emitted when the tab begins to animate towards the center as the active tab. */ - @Output() - onCentering: EventEmitter = new EventEmitter(); + @Output() onCentering: EventEmitter = new EventEmitter(); /** Event emitted when the tab completes its animation towards the center. */ - @Output() - onCentered: EventEmitter = new EventEmitter(true); + @Output() onCentered: EventEmitter = new EventEmitter(true); /** The tab body content to display. */ @Input('content') _content: TemplatePortal; diff --git a/src/lib/tabs/tab-group.ts b/src/lib/tabs/tab-group.ts index 27cc43227540..d8f5818474ae 100644 --- a/src/lib/tabs/tab-group.ts +++ b/src/lib/tabs/tab-group.ts @@ -84,20 +84,11 @@ export class MdTabGroup { return this.selectChange.map(event => event.index); } - private _onFocusChange: EventEmitter = new EventEmitter(); - /** Event emitted when focus has changed within a tab group. */ - @Output() get focusChange(): Observable { - return this._onFocusChange.asObservable(); - } - - private _onSelectChange: EventEmitter = - new EventEmitter(true); + @Output() focusChange: EventEmitter = new EventEmitter(); /** Event emitted when the tab selection has changed. */ - @Output() get selectChange(): Observable { - return this._onSelectChange.asObservable(); - } + @Output() selectChange: EventEmitter = new EventEmitter(true); private _groupId: number; @@ -121,7 +112,7 @@ export class MdTabGroup { // If there is a change in selected index, emit a change event. Should not trigger if // the selected index has not yet been initialized. if (this._selectedIndex != this._indexToSelect && this._selectedIndex != null) { - this._onSelectChange.emit(this._createChangeEvent(this._indexToSelect)); + this.selectChange.emit(this._createChangeEvent(this._indexToSelect)); } // Setup the position for each tab and optionally setup an origin on the next selected tab. @@ -147,7 +138,7 @@ export class MdTabGroup { } _focusChanged(index: number) { - this._onFocusChange.emit(this._createChangeEvent(index)); + this.focusChange.emit(this._createChangeEvent(index)); } private _createChangeEvent(index: number): MdTabChangeEvent {