fix(dynamic_component_loader): leave the view tree in a consistent state when hydration fails
Closes #5718
This commit is contained in:
@ -1,5 +1,12 @@
|
||||
import {NgZone} from 'angular2/src/core/zone/ng_zone';
|
||||
import {Type, isBlank, isPresent, assertionsEnabled, print, IS_DART} from 'angular2/src/facade/lang';
|
||||
import {
|
||||
Type,
|
||||
isBlank,
|
||||
isPresent,
|
||||
assertionsEnabled,
|
||||
print,
|
||||
IS_DART
|
||||
} from 'angular2/src/facade/lang';
|
||||
import {provide, Provider, Injector, OpaqueToken} from 'angular2/src/core/di';
|
||||
import {
|
||||
APP_COMPONENT_REF_PROMISE,
|
||||
|
@ -169,7 +169,7 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
|
||||
// any work done in `hydrateDirectives`.
|
||||
dehydrateDirectives(destroyPipes: boolean): void {}
|
||||
|
||||
hydrated(): boolean { return this.context !== null; }
|
||||
hydrated(): boolean { return isPresent(this.context); }
|
||||
|
||||
afterContentLifecycleCallbacks(): void {
|
||||
this.dispatcher.notifyAfterContentChecked();
|
||||
|
@ -319,9 +319,15 @@ export class AppViewManager_ extends AppViewManager {
|
||||
}
|
||||
this._utils.attachViewInContainer(parentView, boundElementIndex, contextView,
|
||||
contextBoundElementIndex, index, view);
|
||||
this._utils.hydrateViewInContainer(parentView, boundElementIndex, contextView,
|
||||
contextBoundElementIndex, index,
|
||||
imperativelyCreatedInjector);
|
||||
|
||||
try {
|
||||
this._utils.hydrateViewInContainer(parentView, boundElementIndex, contextView,
|
||||
contextBoundElementIndex, index,
|
||||
imperativelyCreatedInjector);
|
||||
} catch (e) {
|
||||
this._utils.detachViewInContainer(parentView, boundElementIndex, index);
|
||||
throw e;
|
||||
}
|
||||
return view.ref;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user