refactor(common): cleanup (#11668)
This commit is contained in:
parent
3a6fcee0e6
commit
0ca971c5bd
|
@ -61,8 +61,7 @@ export class NgPlural {
|
||||||
|
|
||||||
addCase(value: string, switchView: SwitchView): void { this._caseViews[value] = switchView; }
|
addCase(value: string, switchView: SwitchView): void { this._caseViews[value] = switchView; }
|
||||||
|
|
||||||
/** @internal */
|
private _updateView(): void {
|
||||||
_updateView(): void {
|
|
||||||
this._clearViews();
|
this._clearViews();
|
||||||
|
|
||||||
const cases = Object.keys(this._caseViews);
|
const cases = Object.keys(this._caseViews);
|
||||||
|
@ -70,13 +69,11 @@ export class NgPlural {
|
||||||
this._activateView(this._caseViews[key]);
|
this._activateView(this._caseViews[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
private _clearViews() {
|
||||||
_clearViews() {
|
|
||||||
if (this._activeView) this._activeView.destroy();
|
if (this._activeView) this._activeView.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
private _activateView(view: SwitchView) {
|
||||||
_activateView(view: SwitchView) {
|
|
||||||
if (view) {
|
if (view) {
|
||||||
this._activeView = view;
|
this._activeView = view;
|
||||||
this._activeView.create();
|
this._activeView.create();
|
||||||
|
|
|
@ -32,10 +32,8 @@ import {Directive, DoCheck, ElementRef, Input, KeyValueChangeRecord, KeyValueDif
|
||||||
*/
|
*/
|
||||||
@Directive({selector: '[ngStyle]'})
|
@Directive({selector: '[ngStyle]'})
|
||||||
export class NgStyle implements DoCheck {
|
export class NgStyle implements DoCheck {
|
||||||
/** @internal */
|
private _ngStyle: {[key: string]: string};
|
||||||
_ngStyle: {[key: string]: string};
|
private _differ: KeyValueDiffer;
|
||||||
/** @internal */
|
|
||||||
_differ: KeyValueDiffer;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _differs: KeyValueDiffers, private _ngEl: ElementRef, private _renderer: Renderer) {}
|
private _differs: KeyValueDiffers, private _ngEl: ElementRef, private _renderer: Renderer) {}
|
||||||
|
|
|
@ -111,8 +111,7 @@ export class NgSwitch {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
private _emptyAllActiveViews(): void {
|
||||||
_emptyAllActiveViews(): void {
|
|
||||||
const activeContainers = this._activeViews;
|
const activeContainers = this._activeViews;
|
||||||
for (var i = 0; i < activeContainers.length; i++) {
|
for (var i = 0; i < activeContainers.length; i++) {
|
||||||
activeContainers[i].destroy();
|
activeContainers[i].destroy();
|
||||||
|
@ -120,9 +119,7 @@ export class NgSwitch {
|
||||||
this._activeViews = [];
|
this._activeViews = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
private _activateViews(views: SwitchView[]): void {
|
||||||
_activateViews(views: SwitchView[]): void {
|
|
||||||
// TODO(vicb): assert(this._activeViews.length === 0);
|
|
||||||
if (views) {
|
if (views) {
|
||||||
for (var i = 0; i < views.length; i++) {
|
for (var i = 0; i < views.length; i++) {
|
||||||
views[i].create();
|
views[i].create();
|
||||||
|
@ -141,8 +138,7 @@ export class NgSwitch {
|
||||||
views.push(view);
|
views.push(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
private _deregisterView(value: any, view: SwitchView): void {
|
||||||
_deregisterView(value: any, view: SwitchView): void {
|
|
||||||
// `_CASE_DEFAULT` is used a marker for non-registered cases
|
// `_CASE_DEFAULT` is used a marker for non-registered cases
|
||||||
if (value === _CASE_DEFAULT) return;
|
if (value === _CASE_DEFAULT) return;
|
||||||
const views = this._valueViews.get(value);
|
const views = this._valueViews.get(value);
|
||||||
|
@ -181,10 +177,8 @@ export class NgSwitch {
|
||||||
@Directive({selector: '[ngSwitchCase]'})
|
@Directive({selector: '[ngSwitchCase]'})
|
||||||
export class NgSwitchCase {
|
export class NgSwitchCase {
|
||||||
// `_CASE_DEFAULT` is used as a marker for a not yet initialized value
|
// `_CASE_DEFAULT` is used as a marker for a not yet initialized value
|
||||||
/** @internal */
|
private _value: any = _CASE_DEFAULT;
|
||||||
_value: any = _CASE_DEFAULT;
|
private _view: SwitchView;
|
||||||
/** @internal */
|
|
||||||
_view: SwitchView;
|
|
||||||
private _switch: NgSwitch;
|
private _switch: NgSwitch;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|
|
@ -67,7 +67,7 @@ export enum Plural {
|
||||||
Two,
|
Two,
|
||||||
Few,
|
Few,
|
||||||
Many,
|
Many,
|
||||||
Other
|
Other,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -49,16 +49,20 @@ export class Location {
|
||||||
_subject: EventEmitter<any> = new EventEmitter();
|
_subject: EventEmitter<any> = new EventEmitter();
|
||||||
/** @internal */
|
/** @internal */
|
||||||
_baseHref: string;
|
_baseHref: string;
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
_platformStrategy: LocationStrategy;
|
_platformStrategy: LocationStrategy;
|
||||||
|
|
||||||
constructor(platformStrategy: LocationStrategy) {
|
constructor(platformStrategy: LocationStrategy) {
|
||||||
this._platformStrategy = platformStrategy;
|
this._platformStrategy = platformStrategy;
|
||||||
var browserBaseHref = this._platformStrategy.getBaseHref();
|
const browserBaseHref = this._platformStrategy.getBaseHref();
|
||||||
this._baseHref = Location.stripTrailingSlash(_stripIndexHtml(browserBaseHref));
|
this._baseHref = Location.stripTrailingSlash(_stripIndexHtml(browserBaseHref));
|
||||||
this._platformStrategy.onPopState(
|
this._platformStrategy.onPopState((ev) => {
|
||||||
(ev) => { this._subject.emit({'url': this.path(true), 'pop': true, 'type': ev.type}); });
|
this._subject.emit({
|
||||||
|
'url': this.path(true),
|
||||||
|
'pop': true,
|
||||||
|
'type': ev.type,
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,9 +18,7 @@ import {EventEmitter, Injectable} from '@angular/core';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SpyLocation implements Location {
|
export class SpyLocation implements Location {
|
||||||
urlChanges: string[] = [];
|
urlChanges: string[] = [];
|
||||||
/** @internal */
|
|
||||||
private _history: LocationState[] = [new LocationState('', '')];
|
private _history: LocationState[] = [new LocationState('', '')];
|
||||||
/** @internal */
|
|
||||||
private _historyIndex: number = 0;
|
private _historyIndex: number = 0;
|
||||||
/** @internal */
|
/** @internal */
|
||||||
_subject: EventEmitter<any> = new EventEmitter();
|
_subject: EventEmitter<any> = new EventEmitter();
|
||||||
|
|
|
@ -14,15 +14,13 @@ export function unimplemented(): any {
|
||||||
* @stable
|
* @stable
|
||||||
*/
|
*/
|
||||||
export class BaseError extends Error {
|
export class BaseError extends Error {
|
||||||
/**
|
/** @internal **/
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
_nativeError: Error;
|
_nativeError: Error;
|
||||||
|
|
||||||
constructor(message: string) {
|
constructor(message: string) {
|
||||||
// Errors don't use current this, instead they create a new instance.
|
// Errors don't use current this, instead they create a new instance.
|
||||||
// We have to do forward all of our api to the nativeInstance.
|
// We have to do forward all of our api to the nativeInstance.
|
||||||
var nativeError = super(message) as any as Error;
|
const nativeError = super(message) as any as Error;
|
||||||
this._nativeError = nativeError;
|
this._nativeError = nativeError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,11 +38,6 @@ export class BaseError extends Error {
|
||||||
export class WrappedError extends BaseError {
|
export class WrappedError extends BaseError {
|
||||||
originalError: any;
|
originalError: any;
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
_nativeError: Error;
|
|
||||||
|
|
||||||
constructor(message: string, error: any) {
|
constructor(message: string, error: any) {
|
||||||
super(`${message} caused by: ${error instanceof Error ? error.message: error }`);
|
super(`${message} caused by: ${error instanceof Error ? error.message: error }`);
|
||||||
this.originalError = error;
|
this.originalError = error;
|
||||||
|
|
Loading…
Reference in New Issue