fix(query): do not visit dehydrated injectors.
This commit is contained in:
parent
4845583dcf
commit
6c9e712c34
|
@ -486,11 +486,11 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
|
||||||
this._addDirectivesToQueries();
|
this._addDirectivesToQueries();
|
||||||
this._addVarBindingsToQueries();
|
this._addVarBindingsToQueries();
|
||||||
|
|
||||||
|
this.hydrated = true;
|
||||||
|
|
||||||
// TODO(rado): optimize this call, if view queries are not moved around,
|
// TODO(rado): optimize this call, if view queries are not moved around,
|
||||||
// simply appending to the query list is faster than updating.
|
// simply appending to the query list is faster than updating.
|
||||||
this._updateViewQueries();
|
this._updateViewQueries();
|
||||||
|
|
||||||
this.hydrated = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private _updateViewQueries() {
|
private _updateViewQueries() {
|
||||||
|
@ -1164,7 +1164,7 @@ export class QueryRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
visit(inj: ElementInjector, aggregator: any[]): void {
|
visit(inj: ElementInjector, aggregator: any[]): void {
|
||||||
if (isBlank(inj) || !inj._hasQuery(this)) return;
|
if (isBlank(inj) || !inj._hasQuery(this) || !inj.hydrated) return;
|
||||||
|
|
||||||
if (this.query.isVarBindingQuery) {
|
if (this.query.isVarBindingQuery) {
|
||||||
this._aggregateVariableBindings(inj, aggregator);
|
this._aggregateVariableBindings(inj, aggregator);
|
||||||
|
|
|
@ -103,6 +103,24 @@ export function main() {
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should be cleanly destroyed when a query crosses view boundaries',
|
||||||
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
|
var template =
|
||||||
|
'<div text="1"></div>' +
|
||||||
|
'<needs-query text="2"><div *ng-if="shouldShow" [text]="\'3\'"></div></needs-query>' +
|
||||||
|
'<div text="4"></div>';
|
||||||
|
|
||||||
|
tcb.overrideTemplate(MyComp, template)
|
||||||
|
.createAsync(MyComp)
|
||||||
|
.then((rtc) => {
|
||||||
|
rtc.componentInstance.shouldShow = true;
|
||||||
|
rtc.detectChanges();
|
||||||
|
rtc.destroy();
|
||||||
|
|
||||||
|
async.done();
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should reflect moved directives',
|
it('should reflect moved directives',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
var template =
|
var template =
|
||||||
|
|
Loading…
Reference in New Issue