refactor(compiler): make view.disposable
array null if empty
This commit is contained in:
@ -120,8 +120,10 @@ export abstract class AppView<T> {
|
||||
}
|
||||
var hostElement =
|
||||
this.type === ViewType.COMPONENT ? this.declarationAppElement.nativeElement : null;
|
||||
for (var i = 0; i < this.disposables.length; i++) {
|
||||
this.disposables[i]();
|
||||
if (this.disposables) {
|
||||
for (var i = 0; i < this.disposables.length; i++) {
|
||||
this.disposables[i]();
|
||||
}
|
||||
}
|
||||
this.destroyInternal();
|
||||
this.dirtyParentQueriesInternal();
|
||||
|
@ -117,7 +117,12 @@ export class ViewRef_<C> implements EmbeddedViewRef<C>, ChangeDetectorRef {
|
||||
this.markForCheck();
|
||||
}
|
||||
|
||||
onDestroy(callback: Function) { this._view.disposables.push(callback); }
|
||||
onDestroy(callback: Function) {
|
||||
if (!this._view.disposables) {
|
||||
this._view.disposables = [];
|
||||
}
|
||||
this._view.disposables.push(callback);
|
||||
}
|
||||
|
||||
destroy() { this._view.detachAndDestroy(); }
|
||||
}
|
||||
|
Reference in New Issue
Block a user