fix(query): update view queries that query directives in embedded views
Fixes #6747
This commit is contained in:
parent
f4f614f3a9
commit
1f7a41c963
|
@ -463,7 +463,11 @@ export class AppElement implements DependencyProvider, ElementRef, AfterViewChec
|
|||
var inj: AppElement = this;
|
||||
while (isPresent(inj)) {
|
||||
inj._setQueriesAsDirty();
|
||||
inj = inj.parent;
|
||||
if (isBlank(inj.parent) && isPresent(inj.parentView.containerAppElement)) {
|
||||
inj = inj.parentView.containerAppElement;
|
||||
} else {
|
||||
inj = inj.parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -140,6 +140,35 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should contain the first view child accross embedded views',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
var template = '<needs-view-child #q></needs-view-child>';
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.overrideTemplate(
|
||||
NeedsViewChild,
|
||||
'<div *ngIf="true"><div *ngIf="shouldShow" text="foo"></div></div>')
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
view.detectChanges();
|
||||
var q = view.debugElement.componentViewChildren[0].getLocal('q');
|
||||
|
||||
expect(q.log).toEqual([["setter", "foo"], ["init", "foo"], ["check", "foo"]]);
|
||||
|
||||
q.shouldShow = false;
|
||||
view.detectChanges();
|
||||
|
||||
expect(q.log).toEqual([
|
||||
["setter", "foo"],
|
||||
["init", "foo"],
|
||||
["check", "foo"],
|
||||
["setter", null],
|
||||
["check", null]
|
||||
]);
|
||||
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should contain all directives in the light dom when descendants flag is used',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
var template = '<div text="1"></div>' +
|
||||
|
@ -741,7 +770,6 @@ class NeedsViewChild implements AfterViewInit,
|
|||
ngAfterViewChecked() { this.log.push(["check", isPresent(this.child) ? this.child.text : null]); }
|
||||
}
|
||||
|
||||
|
||||
@Directive({selector: '[dir]'})
|
||||
@Injectable()
|
||||
class InertDirective {
|
||||
|
|
Loading…
Reference in New Issue