diff --git a/packages/core/test/acceptance/change_detection_spec.ts b/packages/core/test/acceptance/change_detection_spec.ts
index 596e67e2b7..59aa0c8f96 100644
--- a/packages/core/test/acceptance/change_detection_spec.ts
+++ b/packages/core/test/acceptance/change_detection_spec.ts
@@ -80,7 +80,7 @@ describe('change detection', () => {
})
class TestCmpt {
counter = 0;
- @ViewChild('vc', {read: ViewContainerRef}) vcRef !: ViewContainerRef;
+ @ViewChild('vc', {read: ViewContainerRef, static: false}) vcRef !: ViewContainerRef;
constructor(private _cfr: ComponentFactoryResolver) {}
@@ -146,7 +146,7 @@ describe('change detection', () => {
@Component({selector: 'my-app', template: ''})
class MyApp {
- @ViewChild(MyComponent) comp !: MyComponent;
+ @ViewChild(MyComponent, {static: false}) comp !: MyComponent;
name: string = 'Nancy';
}
@@ -238,7 +238,7 @@ describe('change detection', () => {
template: ''
})
class ButtonParent {
- @ViewChild(MyComponent) comp !: MyComponent;
+ @ViewChild(MyComponent, {static: false}) comp !: MyComponent;
noop() {}
}
@@ -264,7 +264,7 @@ describe('change detection', () => {
changeDetection: ChangeDetectionStrategy.OnPush
})
class ButtonParent implements DoCheck {
- @ViewChild(MyComponent) comp !: MyComponent;
+ @ViewChild(MyComponent, {static: false}) comp !: MyComponent;
noop() {}
doCheckCount = 0;
@@ -273,7 +273,7 @@ describe('change detection', () => {
@Component({selector: 'my-button-app', template: ''})
class MyButtonApp {
- @ViewChild(ButtonParent) parent !: ButtonParent;
+ @ViewChild(ButtonParent, {static: false}) parent !: ButtonParent;
}
TestBed.configureTestingModule({declarations: [MyButtonApp, MyComponent, ButtonParent]});
@@ -326,7 +326,7 @@ describe('change detection', () => {
@Component({selector: 'parent-comp', template: `{{ doCheckCount}} - `})
class ParentComp implements DoCheck {
- @ViewChild(MyComp) myComp !: MyComp;
+ @ViewChild(MyComp, {static: false}) myComp !: MyComp;
doCheckCount = 0;
@@ -411,8 +411,8 @@ describe('change detection', () => {
it('should check component view when called by directive on component node', () => {
@Component({template: ''})
class MyApp {
- @ViewChild(MyComp) myComp !: MyComp;
- @ViewChild(Dir) dir !: Dir;
+ @ViewChild(MyComp, {static: false}) myComp !: MyComp;
+ @ViewChild(Dir, {static: false}) dir !: Dir;
}
TestBed.configureTestingModule({declarations: [MyComp, Dir, MyApp]});
@@ -429,8 +429,8 @@ describe('change detection', () => {
it('should check host component when called by directive on element node', () => {
@Component({template: '{{ value }}
'})
class MyApp {
- @ViewChild(MyComp) myComp !: MyComp;
- @ViewChild(Dir) dir !: Dir;
+ @ViewChild(MyComp, {static: false}) myComp !: MyComp;
+ @ViewChild(Dir, {static: false}) dir !: Dir;
value = '';
}
@@ -450,7 +450,7 @@ describe('change detection', () => {
it('should check the host component when called from EmbeddedViewRef', () => {
@Component({template: '{{ name }}'})
class MyApp {
- @ViewChild(Dir) dir !: Dir;
+ @ViewChild(Dir, {static: false}) dir !: Dir;
showing = true;
name = 'Amelia';
}
@@ -563,7 +563,7 @@ describe('change detection', () => {
'{{ ctx.value }}'
})
class App {
- @ViewChild(StructuralComp) structuralComp !: StructuralComp;
+ @ViewChild(StructuralComp, {static: false}) structuralComp !: StructuralComp;
}
TestBed.configureTestingModule({declarations: [App, StructuralComp]});
@@ -592,7 +592,7 @@ describe('change detection', () => {
template: 'Template text'
})
class App {
- @ViewChild(StructuralComp) structuralComp !: StructuralComp;
+ @ViewChild(StructuralComp, {static: false}) structuralComp !: StructuralComp;
}
TestBed.configureTestingModule({declarations: [App, StructuralComp]});
@@ -623,7 +623,7 @@ describe('change detection', () => {
@Component({template: ''})
class MyApp {
- @ViewChild(DetachedComp) comp !: DetachedComp;
+ @ViewChild(DetachedComp, {static: false}) comp !: DetachedComp;
constructor(public cdr: ChangeDetectorRef) {}
}
@@ -734,7 +734,7 @@ describe('change detection', () => {
@Component({template: ''})
class OnPushApp {
- @ViewChild(OnPushComp) onPushComp !: OnPushComp;
+ @ViewChild(OnPushComp, {static: false}) onPushComp !: OnPushComp;
value = '';
}
@@ -781,7 +781,7 @@ describe('change detection', () => {
changeDetection: ChangeDetectionStrategy.OnPush
})
class OnPushParent {
- @ViewChild(OnPushComp) comp !: OnPushComp;
+ @ViewChild(OnPushComp, {static: false}) comp !: OnPushComp;
value = 'one';
}
@@ -843,7 +843,7 @@ describe('change detection', () => {
changeDetection: ChangeDetectionStrategy.OnPush
})
class EmbeddedViewParent {
- @ViewChild(OnPushComp) comp !: OnPushComp;
+ @ViewChild(OnPushComp, {static: false}) comp !: OnPushComp;
value = 'one';
showing = true;
}
diff --git a/packages/core/test/acceptance/component_spec.ts b/packages/core/test/acceptance/component_spec.ts
index 940e1dc5f1..7fe1e54939 100644
--- a/packages/core/test/acceptance/component_spec.ts
+++ b/packages/core/test/acceptance/component_spec.ts
@@ -70,7 +70,7 @@ describe('component', () => {
entryComponents: [OtherComponent]
})
class TestComponent {
- @ViewChild('vc', {read: ViewContainerRef}) vcref !: ViewContainerRef;
+ @ViewChild('vc', {read: ViewContainerRef, static: true}) vcref !: ViewContainerRef;
constructor(private _cfr: ComponentFactoryResolver) {}
diff --git a/packages/core/test/acceptance/content_spec.ts b/packages/core/test/acceptance/content_spec.ts
index c84aa1d5fc..5673111585 100644
--- a/packages/core/test/acceptance/content_spec.ts
+++ b/packages/core/test/acceptance/content_spec.ts
@@ -245,7 +245,7 @@ describe('projection', () => {
@Component(
{selector: 'comp', template: ``})
class Comp {
- @ViewChild(TemplateRef) template !: TemplateRef;
+ @ViewChild(TemplateRef, {static: true}) template !: TemplateRef;
}
@Directive({selector: '[trigger]'})
diff --git a/packages/core/test/acceptance/di_spec.ts b/packages/core/test/acceptance/di_spec.ts
index a60bf34bbb..a624e478ac 100644
--- a/packages/core/test/acceptance/di_spec.ts
+++ b/packages/core/test/acceptance/di_spec.ts
@@ -377,7 +377,7 @@ describe('di', () => {
`
})
class MyComp {
- @ViewChild(StructuralDirective) structuralDir !: StructuralDirective;
+ @ViewChild(StructuralDirective, {static: false}) structuralDir !: StructuralDirective;
}
TestBed.configureTestingModule(
@@ -421,8 +421,8 @@ describe('di', () => {
`
})
class MyApp {
- @ViewChild(HostBindingDirective) hostBindingDir !: HostBindingDirective;
- @ViewChild(DirectiveA) dirA !: DirectiveA;
+ @ViewChild(HostBindingDirective, {static: false}) hostBindingDir !: HostBindingDirective;
+ @ViewChild(DirectiveA, {static: false}) dirA !: DirectiveA;
}
TestBed.configureTestingModule(
@@ -535,7 +535,7 @@ describe('di', () => {
@Component({template: ''})
class MyComp {
- @ViewChild(DirectiveA) dirA !: DirectiveA;
+ @ViewChild(DirectiveA, {static: false}) dirA !: DirectiveA;
}
TestBed.configureTestingModule({declarations: [DirectiveA, DirectiveB, MyComp]});
@@ -555,7 +555,7 @@ describe('di', () => {
@Component({template: ''})
class MyComp {
- @ViewChild(DirectiveC) dirC !: DirectiveC;
+ @ViewChild(DirectiveC, {static: false}) dirC !: DirectiveC;
}
TestBed.configureTestingModule({declarations: [DirectiveC, MyComp]});
@@ -575,7 +575,7 @@ describe('di', () => {
@Component({template: ''})
class MyComp {
- @ViewChild(DirectiveC) dirC !: DirectiveC;
+ @ViewChild(DirectiveC, {static: false}) dirC !: DirectiveC;
}
TestBed.configureTestingModule({declarations: [DirectiveB, DirectiveC, MyComp]});
@@ -596,12 +596,12 @@ describe('di', () => {
@Component({selector: 'my-comp', template: ''})
class MyComp {
- @ViewChild(DirectiveA) dirA !: DirectiveA;
+ @ViewChild(DirectiveA, {static: false}) dirA !: DirectiveA;
}
@Component({template: ''})
class MyApp {
- @ViewChild(MyComp) myComp !: MyComp;
+ @ViewChild(MyComp, {static: false}) myComp !: MyComp;
}
TestBed.configureTestingModule({declarations: [DirectiveA, DirectiveB, MyComp, MyApp]});
@@ -646,12 +646,12 @@ describe('di', () => {
viewProviders: [{provide: String, useValue: 'Foo'}]
})
class MyComp {
- @ViewChild(DirectiveString) dirString !: DirectiveString;
+ @ViewChild(DirectiveString, {static: false}) dirString !: DirectiveString;
}
@Component({template: ''})
class MyApp {
- @ViewChild(MyComp) myComp !: MyComp;
+ @ViewChild(MyComp, {static: false}) myComp !: MyComp;
}
TestBed.configureTestingModule({declarations: [DirectiveString, MyComp, MyApp]});
@@ -670,12 +670,12 @@ describe('di', () => {
@Component({selector: 'my-comp', template: ''})
class MyComp {
- @ViewChild(DirectiveComp) dirComp !: DirectiveComp;
+ @ViewChild(DirectiveComp, {static: false}) dirComp !: DirectiveComp;
}
@Component({template: ''})
class MyApp {
- @ViewChild(MyComp) myComp !: MyComp;
+ @ViewChild(MyComp, {static: false}) myComp !: MyComp;
}
TestBed.configureTestingModule({declarations: [DirectiveComp, MyComp, MyApp]});
@@ -734,7 +734,7 @@ describe('di', () => {
@Component({template: ''})
class MyApp {
- @ViewChild(MyComp) myComp !: MyComp;
+ @ViewChild(MyComp, {static: false}) myComp !: MyComp;
}
TestBed.configureTestingModule(
@@ -751,8 +751,8 @@ describe('di', () => {
@Component({template: ''})
class MyApp {
showing = false;
- @ViewChild(DirectiveA) dirA !: DirectiveA;
- @ViewChild(DirectiveB) dirB !: DirectiveB;
+ @ViewChild(DirectiveA, {static: false}) dirA !: DirectiveA;
+ @ViewChild(DirectiveB, {static: false}) dirB !: DirectiveB;
}
TestBed.configureTestingModule({declarations: [DirectiveA, DirectiveB, MyApp]});
@@ -952,8 +952,8 @@ describe('di', () => {
@Component({template: ''})
class MyComp {
- @ViewChild(InjectorDir) injectorDir !: InjectorDir;
- @ViewChild(OtherInjectorDir) otherInjectorDir !: OtherInjectorDir;
+ @ViewChild(InjectorDir, {static: false}) injectorDir !: InjectorDir;
+ @ViewChild(OtherInjectorDir, {static: false}) otherInjectorDir !: OtherInjectorDir;
}
TestBed.configureTestingModule({declarations: [InjectorDir, OtherInjectorDir, MyComp]});
@@ -978,7 +978,7 @@ describe('di', () => {
@Component({template: ''})
class MyComp {
- @ViewChild(InjectorDir) injectorDir !: InjectorDir;
+ @ViewChild(InjectorDir, {static: false}) injectorDir !: InjectorDir;
}
TestBed.configureTestingModule({declarations: [InjectorDir, MyComp]});
@@ -1015,8 +1015,8 @@ describe('di', () => {
@Component({template: ''})
class MyComp {
- @ViewChild(MyDir) directive !: MyDir;
- @ViewChild(MyOtherDir) otherDirective !: MyOtherDir;
+ @ViewChild(MyDir, {static: false}) directive !: MyDir;
+ @ViewChild(MyOtherDir, {static: false}) otherDirective !: MyOtherDir;
}
TestBed.configureTestingModule({declarations: [MyDir, MyOtherDir, MyComp]});
@@ -1047,7 +1047,7 @@ describe('di', () => {
@Component({template: ''})
class MyComp {
- @ViewChild(MyDir) directive !: MyDir;
+ @ViewChild(MyDir, {static: false}) directive !: MyDir;
}
TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
@@ -1085,8 +1085,8 @@ describe('di', () => {
template: ''
})
class MyComp {
- @ViewChild(MyDir) directive !: MyDir;
- @ViewChild(MyOtherDir) otherDirective !: MyOtherDir;
+ @ViewChild(MyDir, {static: false}) directive !: MyDir;
+ @ViewChild(MyOtherDir, {static: false}) otherDirective !: MyOtherDir;
}
TestBed.configureTestingModule({declarations: [MyDir, MyOtherDir, MyComp]});
@@ -1129,7 +1129,7 @@ describe('di', () => {
}
@Component({template: ''})
class MyComp {
- @ViewChild(OptionalDir) directive !: OptionalDir;
+ @ViewChild(OptionalDir, {static: false}) directive !: OptionalDir;
}
TestBed.configureTestingModule({declarations: [OptionalDir, MyComp]});
@@ -1158,8 +1158,8 @@ describe('di', () => {
}
@Component({template: ''})
class MyComp {
- @ViewChild(MyDir) directive !: MyDir;
- @ViewChild(MyOtherDir) otherDirective !: MyOtherDir;
+ @ViewChild(MyDir, {static: false}) directive !: MyDir;
+ @ViewChild(MyOtherDir, {static: false}) otherDirective !: MyOtherDir;
}
TestBed.configureTestingModule({declarations: [MyDir, MyOtherDir, MyComp]});
@@ -1224,9 +1224,9 @@ describe('di', () => {
() => {
@Component({selector: 'my-app', template: ''})
class MyApp {
- @ViewChild(MyComp) component !: MyComp;
- @ViewChild(MyDir) directive !: MyDir;
- @ViewChild(MyOtherDir) otherDirective !: MyOtherDir;
+ @ViewChild(MyComp, {static: false}) component !: MyComp;
+ @ViewChild(MyDir, {static: false}) directive !: MyDir;
+ @ViewChild(MyOtherDir, {static: false}) otherDirective !: MyOtherDir;
}
TestBed.configureTestingModule({declarations: [MyApp, MyComp, MyDir, MyOtherDir]});
const fixture = TestBed.createComponent(MyApp);
@@ -1247,8 +1247,8 @@ describe('di', () => {
@Component({selector: 'my-comp', template: ''})
class MyComp {
constructor(public cdr: ChangeDetectorRef) {}
- @ViewChild(MyDir) directive !: MyDir;
- @ViewChild(MyOtherDir) otherDirective !: MyOtherDir;
+ @ViewChild(MyDir, {static: false}) directive !: MyDir;
+ @ViewChild(MyOtherDir, {static: false}) otherDirective !: MyOtherDir;
}
TestBed.configureTestingModule({declarations: [MyComp, MyDir, MyOtherDir]});
const fixture = TestBed.createComponent(MyComp);
@@ -1274,9 +1274,9 @@ describe('di', () => {
})
class MyApp {
constructor(public cdr: ChangeDetectorRef) {}
- @ViewChild(MyComp) component !: MyComp;
- @ViewChild(MyDir) directive !: MyDir;
- @ViewChild(MyOtherDir) otherDirective !: MyOtherDir;
+ @ViewChild(MyComp, {static: false}) component !: MyComp;
+ @ViewChild(MyDir, {static: false}) directive !: MyDir;
+ @ViewChild(MyOtherDir, {static: false}) otherDirective !: MyOtherDir;
}
TestBed.configureTestingModule({declarations: [MyApp, MyComp, MyDir, MyOtherDir]});
const fixture = TestBed.createComponent(MyApp);
@@ -1302,8 +1302,8 @@ describe('di', () => {
class MyComp {
showing = true;
constructor(public cdr: ChangeDetectorRef) {}
- @ViewChild(MyDir) directive !: MyDir;
- @ViewChild(MyOtherDir) otherDirective !: MyOtherDir;
+ @ViewChild(MyDir, {static: false}) directive !: MyDir;
+ @ViewChild(MyOtherDir, {static: false}) otherDirective !: MyOtherDir;
}
TestBed.configureTestingModule({declarations: [MyComp, MyDir, MyOtherDir]});
@@ -1325,8 +1325,8 @@ describe('di', () => {
class MyComp {
showing = true;
constructor(public cdr: ChangeDetectorRef) {}
- @ViewChild(MyDir) directive !: MyDir;
- @ViewChild(MyOtherDir) otherDirective !: MyOtherDir;
+ @ViewChild(MyDir, {static: false}) directive !: MyDir;
+ @ViewChild(MyOtherDir, {static: false}) otherDirective !: MyOtherDir;
}
TestBed.configureTestingModule({declarations: [MyComp, MyDir, MyOtherDir]});
@@ -1375,7 +1375,7 @@ describe('di', () => {
@Component({template: ''})
class MyComp {
- @ViewChild(InjectorDir) injectorDirInstance !: InjectorDir;
+ @ViewChild(InjectorDir, {static: false}) injectorDirInstance !: InjectorDir;
}
TestBed.configureTestingModule({declarations: [InjectorDir, MyComp]});
@@ -1468,7 +1468,7 @@ describe('di', () => {
providers: [{provide: LOCALE_ID, useValue: 'en-GB'}]
})
class MyComp {
- @ViewChild(MyDir) myDir !: MyDir;
+ @ViewChild(MyDir, {static: false}) myDir !: MyDir;
constructor(@Inject(LOCALE_ID) public localeId: string) {}
}
@@ -1490,7 +1490,7 @@ describe('di', () => {
@Component({template: ''})
class MyComp {
- @ViewChild(MyDir) directiveInstance !: MyDir;
+ @ViewChild(MyDir, {static: false}) directiveInstance !: MyDir;
}
TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
@@ -1514,7 +1514,7 @@ describe('di', () => {
@Component(
{template: ''})
class MyComp {
- @ViewChild(MyDir) directiveInstance !: MyDir;
+ @ViewChild(MyDir, {static: false}) directiveInstance !: MyDir;
}
TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
@@ -1539,7 +1539,7 @@ describe('di', () => {
template: ''
})
class MyComp {
- @ViewChild(MyDir) directiveInstance !: MyDir;
+ @ViewChild(MyDir, {static: false}) directiveInstance !: MyDir;
}
TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
@@ -1566,7 +1566,7 @@ describe('di', () => {
''
})
class MyComp {
- @ViewChild(MyDir) directiveInstance !: MyDir;
+ @ViewChild(MyDir, {static: false}) directiveInstance !: MyDir;
}
TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
@@ -1593,7 +1593,7 @@ describe('di', () => {
template: ''
})
class MyComp {
- @ViewChild(MyDir) directiveInstance !: MyDir;
+ @ViewChild(MyDir, {static: false}) directiveInstance !: MyDir;
}
TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
@@ -1624,7 +1624,7 @@ describe('di', () => {
''
})
class MyComp {
- @ViewChild(MyDir) directiveInstance !: MyDir;
+ @ViewChild(MyDir, {static: false}) directiveInstance !: MyDir;
}
TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
diff --git a/packages/core/test/acceptance/directive_spec.ts b/packages/core/test/acceptance/directive_spec.ts
index 4ff44eb326..e6d7dde5c7 100644
--- a/packages/core/test/acceptance/directive_spec.ts
+++ b/packages/core/test/acceptance/directive_spec.ts
@@ -213,7 +213,7 @@ describe('directives', () => {
it('should allow outputs of directive on ng-template', () => {
@Component({template: ``})
class TestComp {
- @ViewChild(TestDir) testDir: TestDir|undefined;
+ @ViewChild(TestDir, {static: true}) testDir: TestDir|undefined;
value = false;
}
diff --git a/packages/core/test/acceptance/discover_utils_spec.ts b/packages/core/test/acceptance/discover_utils_spec.ts
index d55eb3d91d..6c13d569f0 100644
--- a/packages/core/test/acceptance/discover_utils_spec.ts
+++ b/packages/core/test/acceptance/discover_utils_spec.ts
@@ -312,9 +312,9 @@ onlyInIvy('Ivy-specific utilities').describe('discovery utils deprecated', () =>
`
})
class Comp {
- @ViewChild(MyDir1) myDir1Instance !: MyDir1;
- @ViewChild(MyDir2) myDir2Instance !: MyDir2;
- @ViewChild(MyDir3) myDir3Instance !: MyDir3;
+ @ViewChild(MyDir1, {static: false}) myDir1Instance !: MyDir1;
+ @ViewChild(MyDir2, {static: false}) myDir2Instance !: MyDir2;
+ @ViewChild(MyDir3, {static: false}) myDir3Instance !: MyDir3;
}
TestBed.configureTestingModule({declarations: [Comp, MyDir1, MyDir2, MyDir3]});
diff --git a/packages/core/test/acceptance/host_binding_spec.ts b/packages/core/test/acceptance/host_binding_spec.ts
index cb61683447..4e0d3e17b0 100644
--- a/packages/core/test/acceptance/host_binding_spec.ts
+++ b/packages/core/test/acceptance/host_binding_spec.ts
@@ -121,7 +121,7 @@ describe('host bindings', () => {
class ParentCmp {
private _prop = '';
- @ViewChild('template', {read: ViewContainerRef})
+ @ViewChild('template', {read: ViewContainerRef, static: false})
vcr: ViewContainerRef = null !;
private child: ComponentRef = null !;
@@ -314,7 +314,7 @@ describe('host bindings', () => {
@Component({template: ''})
class App {
- @ViewChild(Dir) directiveInstance !: Dir;
+ @ViewChild(Dir, {static: false}) directiveInstance !: Dir;
}
TestBed.configureTestingModule({declarations: [App, Dir]});
@@ -403,7 +403,7 @@ describe('host bindings', () => {
`
})
class App {
- @ViewChild(HostBindingDir) hostBindingDir !: HostBindingDir;
+ @ViewChild(HostBindingDir, {static: false}) hostBindingDir !: HostBindingDir;
}
TestBed.configureTestingModule({declarations: [App, SomeDir, HostTitleComp, HostBindingDir]});
@@ -471,7 +471,7 @@ describe('host bindings', () => {
@Component({template: ''})
class App {
- @ViewChild(HostBindingDir) hostBindingDir !: HostBindingDir;
+ @ViewChild(HostBindingDir, {static: false}) hostBindingDir !: HostBindingDir;
}
TestBed.configureTestingModule({declarations: [App, SomeDir, HostBindingDir]});
@@ -539,7 +539,7 @@ describe('host bindings', () => {
@Component({template: ''})
class App {
- @ViewChild(HostBindingInputDir) hostBindingInputDir !: HostBindingInputDir;
+ @ViewChild(HostBindingInputDir, {static: false}) hostBindingInputDir !: HostBindingInputDir;
isDisabled = true;
}
@@ -629,7 +629,7 @@ describe('host bindings', () => {
`
})
class App {
- @ViewChild(NameComp) nameComp !: NameComp;
+ @ViewChild(NameComp, {static: false}) nameComp !: NameComp;
name = '';
}
@@ -685,8 +685,8 @@ describe('host bindings', () => {
`
})
class App {
- @ViewChild(HostBindingComp) hostBindingComp !: HostBindingComp;
- @ViewChild(NameComp) nameComp !: NameComp;
+ @ViewChild(HostBindingComp, {static: false}) hostBindingComp !: HostBindingComp;
+ @ViewChild(NameComp, {static: false}) nameComp !: NameComp;
name = '';
otherName = '';
}
@@ -760,8 +760,8 @@ describe('host bindings', () => {
@Component({template: ''})
class App {
- @ViewChild(HostBindingComp) hostBindingComp !: HostBindingComp;
- @ViewChild(HostBindingDir) hostBindingDir !: HostBindingDir;
+ @ViewChild(HostBindingComp, {static: false}) hostBindingComp !: HostBindingComp;
+ @ViewChild(HostBindingDir, {static: false}) hostBindingDir !: HostBindingDir;
}
TestBed.configureTestingModule({declarations: [App, HostBindingComp, HostBindingDir]});
@@ -799,7 +799,7 @@ describe('host bindings', () => {
@Component({template: `{{ name }}`})
class App {
- @ViewChild(HostBindingComp) hostBindingComp !: HostBindingComp;
+ @ViewChild(HostBindingComp, {static: false}) hostBindingComp !: HostBindingComp;
name = '';
}
@@ -849,8 +849,8 @@ describe('host bindings', () => {
`
})
class App {
- @ViewChild(SubDirective) subDir !: SubDirective;
- @ViewChild(SuperDirective) superDir !: SuperDirective;
+ @ViewChild(SubDirective, {static: false}) subDir !: SubDirective;
+ @ViewChild(SuperDirective, {static: false}) superDir !: SuperDirective;
}
TestBed.configureTestingModule({declarations: [App, SuperDirective, SubDirective]});
@@ -958,7 +958,7 @@ describe('host bindings', () => {
@Component({template: ''})
class App {
- @ViewChild(HostBindingToStyles) hostBindingDir !: HostBindingToStyles;
+ @ViewChild(HostBindingToStyles, {static: false}) hostBindingDir !: HostBindingToStyles;
}
TestBed.configureTestingModule({declarations: [App, HostBindingToStyles]});
@@ -987,7 +987,7 @@ describe('host bindings', () => {
@Component({template: ''})
class App {
- @ViewChild(HostBindingToStyles) hostBindingDir !: HostBindingToStyles;
+ @ViewChild(HostBindingToStyles, {static: false}) hostBindingDir !: HostBindingToStyles;
}
TestBed.configureTestingModule({declarations: [App, HostBindingToStyles, ContainerDir]});
@@ -1037,7 +1037,7 @@ describe('host bindings', () => {
@Component({template: `<${tag} unsafeUrlHostBindingDir>${tag}>`})
class App {
- @ViewChild(UnsafeDir) unsafeDir !: UnsafeDir;
+ @ViewChild(UnsafeDir, {static: false}) unsafeDir !: UnsafeDir;
}
TestBed.configureTestingModule({declarations: [App, UnsafeDir]});
diff --git a/packages/core/test/acceptance/i18n_spec.ts b/packages/core/test/acceptance/i18n_spec.ts
index 9679058eb2..046aad5755 100644
--- a/packages/core/test/acceptance/i18n_spec.ts
+++ b/packages/core/test/acceptance/i18n_spec.ts
@@ -896,10 +896,10 @@ onlyInIvy('Ivy i18n logic').describe('runtime i18n', () => {
@Component({selector: 'div-query', template: ''})
class DivQuery {
// TODO(issue/24571): remove '!'.
- @ContentChild(TemplateRef) template !: TemplateRef;
+ @ContentChild(TemplateRef, {static: true}) template !: TemplateRef;
// TODO(issue/24571): remove '!'.
- @ViewChild('vc', {read: ViewContainerRef})
+ @ViewChild('vc', {read: ViewContainerRef, static: true})
vc !: ViewContainerRef;
// TODO(issue/24571): remove '!'.
diff --git a/packages/core/test/acceptance/integration_spec.ts b/packages/core/test/acceptance/integration_spec.ts
index be4b6b58cc..2a59030167 100644
--- a/packages/core/test/acceptance/integration_spec.ts
+++ b/packages/core/test/acceptance/integration_spec.ts
@@ -143,7 +143,7 @@ describe('acceptance integration tests', () => {
template: 'content'
})
class App {
- @ViewChild(TestDirective) testDirective !: TestDirective;
+ @ViewChild(TestDirective, {static: true}) testDirective !: TestDirective;
}
TestBed.configureTestingModule({declarations: [App, TestDirective]});
@@ -213,7 +213,7 @@ describe('acceptance integration tests', () => {
'content'
})
class App {
- @ViewChild(TestDirective) testDirective !: TestDirective;
+ @ViewChild(TestDirective, {static: true}) testDirective !: TestDirective;
}
TestBed.configureTestingModule({declarations: [App, TestDirective]});
@@ -243,7 +243,7 @@ describe('acceptance integration tests', () => {
@Component({template: '
'})
class App {
- @ViewChild(TestDirective) testDirective !: TestDirective;
+ @ViewChild(TestDirective, {static: false}) testDirective !: TestDirective;
}
TestBed.configureTestingModule({declarations: [App, TestDirective]});
@@ -273,7 +273,7 @@ describe('acceptance integration tests', () => {
'Content'
})
class App {
- @ViewChild(TestDirective) testDirective !: TestDirective;
+ @ViewChild(TestDirective, {static: false}) testDirective !: TestDirective;
}
TestBed.configureTestingModule({declarations: [App, TestDirective]});
@@ -303,7 +303,7 @@ describe('acceptance integration tests', () => {
@Component({template: 'Content'})
class App {
- @ViewChild(TestDirective) testDirective !: TestDirective;
+ @ViewChild(TestDirective, {static: false}) testDirective !: TestDirective;
}
TestBed.configureTestingModule({declarations: [App, TestDirective]});
@@ -608,7 +608,8 @@ describe('acceptance integration tests', () => {
@Component({template: ''})
class App {
- @ViewChild(TodoComponentHostBinding) todoComponentHostBinding !: TodoComponentHostBinding;
+ @ViewChild(TodoComponentHostBinding, {static: false})
+ todoComponentHostBinding !: TodoComponentHostBinding;
}
TestBed.configureTestingModule({declarations: [App, TodoComponentHostBinding]});
@@ -843,7 +844,7 @@ describe('acceptance integration tests', () => {
@Component({template: ''})
class App {
- @ViewChild(HostBindingDir) hostBindingDir !: HostBindingDir;
+ @ViewChild(HostBindingDir, {static: false}) hostBindingDir !: HostBindingDir;
}
TestBed.configureTestingModule({declarations: [App, HostBindingDir]});
@@ -1011,7 +1012,7 @@ describe('acceptance integration tests', () => {
`
})
class App {
- @ViewChild(StructuralComp) structuralComp !: StructuralComp;
+ @ViewChild(StructuralComp, {static: false}) structuralComp !: StructuralComp;
value: any;
}
@@ -1052,7 +1053,8 @@ describe('acceptance integration tests', () => {
() => {
@Component({template: ''})
class App {
- @ViewChild(DirWithClassDirective) mockClassDirective !: DirWithClassDirective;
+ @ViewChild(DirWithClassDirective, {static: false})
+ mockClassDirective !: DirWithClassDirective;
}
TestBed.configureTestingModule({declarations: [App, DirWithClassDirective]});
@@ -1067,7 +1069,8 @@ describe('acceptance integration tests', () => {
() => {
@Component({template: ''})
class App {
- @ViewChild(DirWithStyleDirective) mockStyleDirective !: DirWithStyleDirective;
+ @ViewChild(DirWithStyleDirective, {static: false})
+ mockStyleDirective !: DirWithStyleDirective;
}
TestBed.configureTestingModule({declarations: [App, DirWithStyleDirective]});
@@ -1085,7 +1088,8 @@ describe('acceptance integration tests', () => {
() => {
@Component({template: ''})
class App {
- @ViewChild(DirWithClassDirective) mockClassDirective !: DirWithClassDirective;
+ @ViewChild(DirWithClassDirective, {static: false})
+ mockClassDirective !: DirWithClassDirective;
value = '';
}
@@ -1103,7 +1107,8 @@ describe('acceptance integration tests', () => {
() => {
@Component({template: ''})
class App {
- @ViewChild(DirWithStyleDirective) mockStyleDirective !: DirWithStyleDirective;
+ @ViewChild(DirWithStyleDirective, {static: false})
+ mockStyleDirective !: DirWithStyleDirective;
value !: {[key: string]: string};
}
@@ -1179,7 +1184,7 @@ describe('acceptance integration tests', () => {
`
})
class App {
- @ViewChild(DirWithSingleStylingBindings)
+ @ViewChild(DirWithSingleStylingBindings, {static: false})
dirInstance !: DirWithSingleStylingBindings;
}
@@ -1235,8 +1240,8 @@ describe('acceptance integration tests', () => {
@Component(
{template: ''})
class App {
- @ViewChild(Dir1WithStyle) dir1Instance !: Dir1WithStyle;
- @ViewChild(Dir2WithStyle) dir2Instance !: Dir2WithStyle;
+ @ViewChild(Dir1WithStyle, {static: false}) dir1Instance !: Dir1WithStyle;
+ @ViewChild(Dir2WithStyle, {static: false}) dir2Instance !: Dir2WithStyle;
width: string|null = null;
}
@@ -1300,8 +1305,8 @@ describe('acceptance integration tests', () => {
''
})
class App {
- @ViewChild(Dir1WithStyling) dir1Instance !: Dir1WithStyling;
- @ViewChild(Dir2WithStyling) dir2Instance !: Dir2WithStyling;
+ @ViewChild(Dir1WithStyling, {static: false}) dir1Instance !: Dir1WithStyling;
+ @ViewChild(Dir2WithStyling, {static: false}) dir2Instance !: Dir2WithStyling;
stylesExp: any = {};
classesExp: any = {};
}
@@ -1491,7 +1496,7 @@ describe('acceptance integration tests', () => {
@Component(
{selector: 'test-component', template: `foo`, host: {'[attr.aria-disabled]': 'true'}})
class TestComponent {
- @ContentChild(TemplateRef) tpl !: TemplateRef;
+ @ContentChild(TemplateRef, {static: true}) tpl !: TemplateRef;
}
TestBed.configureTestingModule({declarations: [TestComponent]});
diff --git a/packages/core/test/acceptance/lifecycle_spec.ts b/packages/core/test/acceptance/lifecycle_spec.ts
index 5175d3dd7d..77d6d37161 100644
--- a/packages/core/test/acceptance/lifecycle_spec.ts
+++ b/packages/core/test/acceptance/lifecycle_spec.ts
@@ -1293,7 +1293,7 @@ describe('onInit', () => {
`,
})
class App {
- @ViewChild('container', {read: ViewContainerRef})
+ @ViewChild('container', {read: ViewContainerRef, static: false})
viewContainerRef !: ViewContainerRef;
constructor(public compFactoryResolver: ComponentFactoryResolver) {}
diff --git a/packages/core/test/acceptance/listener_spec.ts b/packages/core/test/acceptance/listener_spec.ts
index 044520b060..52dfca3b00 100644
--- a/packages/core/test/acceptance/listener_spec.ts
+++ b/packages/core/test/acceptance/listener_spec.ts
@@ -220,7 +220,7 @@ describe('event listeners', () => {
count = 0;
someValue = -1;
- @ViewChild(FooDirective) fooDirective: FooDirective|null = null;
+ @ViewChild(FooDirective, {static: false}) fooDirective: FooDirective|null = null;
fooChange() { this.count++; }
diff --git a/packages/core/test/acceptance/outputs_spec.ts b/packages/core/test/acceptance/outputs_spec.ts
index 873b663388..35716f1625 100644
--- a/packages/core/test/acceptance/outputs_spec.ts
+++ b/packages/core/test/acceptance/outputs_spec.ts
@@ -43,7 +43,7 @@ describe('outputs', () => {
@Component({template: ''})
class App {
- @ViewChild(ButtonToggle) buttonToggle !: ButtonToggle;
+ @ViewChild(ButtonToggle, {static: false}) buttonToggle !: ButtonToggle;
onChange() { counter++; }
}
TestBed.configureTestingModule({declarations: [App, ButtonToggle]});
@@ -64,7 +64,7 @@ describe('outputs', () => {
@Component(
{template: ''})
class App {
- @ViewChild(ButtonToggle) buttonToggle !: ButtonToggle;
+ @ViewChild(ButtonToggle, {static: false}) buttonToggle !: ButtonToggle;
onChange() { counter++; }
onReset() { resetCounter++; }
}
@@ -82,7 +82,7 @@ describe('outputs', () => {
it('should eval component output expression when event is emitted', () => {
@Component({template: ''})
class App {
- @ViewChild(ButtonToggle) buttonToggle !: ButtonToggle;
+ @ViewChild(ButtonToggle, {static: false}) buttonToggle !: ButtonToggle;
counter = 0;
}
TestBed.configureTestingModule({declarations: [App, ButtonToggle]});
@@ -102,7 +102,7 @@ describe('outputs', () => {
@Component(
{template: ''})
class App {
- @ViewChild(ButtonToggle) buttonToggle !: ButtonToggle;
+ @ViewChild(ButtonToggle, {static: false}) buttonToggle !: ButtonToggle;
condition = true;
onChange() { counter++; }
@@ -133,7 +133,7 @@ describe('outputs', () => {
`
})
class App {
- @ViewChild(ButtonToggle) buttonToggle !: ButtonToggle;
+ @ViewChild(ButtonToggle, {static: false}) buttonToggle !: ButtonToggle;
condition = true;
condition2 = true;
@@ -168,8 +168,8 @@ describe('outputs', () => {
`
})
class App {
- @ViewChild(ButtonToggle) buttonToggle !: ButtonToggle;
- @ViewChild(DestroyComp) destroyComp !: DestroyComp;
+ @ViewChild(ButtonToggle, {static: false}) buttonToggle !: ButtonToggle;
+ @ViewChild(DestroyComp, {static: false}) destroyComp !: DestroyComp;
condition = true;
onClick() { clickCounter++; }
@@ -206,7 +206,7 @@ describe('outputs', () => {
@Component({template: ''})
class App {
- @ViewChild(MyButton) buttonDir !: MyButton;
+ @ViewChild(MyButton, {static: false}) buttonDir !: MyButton;
onClick() { counter++; }
}
TestBed.configureTestingModule({declarations: [App, MyButton]});
@@ -228,8 +228,8 @@ describe('outputs', () => {
@Component({template: ''})
class App {
- @ViewChild(ButtonToggle) buttonToggle !: ButtonToggle;
- @ViewChild(OtherDir) otherDir !: OtherDir;
+ @ViewChild(ButtonToggle, {static: false}) buttonToggle !: ButtonToggle;
+ @ViewChild(OtherDir, {static: false}) otherDir !: OtherDir;
onChange() { counter++; }
}
TestBed.configureTestingModule({declarations: [App, ButtonToggle, OtherDir]});
@@ -257,8 +257,8 @@ describe('outputs', () => {
''
})
class App {
- @ViewChild(ButtonToggle) buttonToggle !: ButtonToggle;
- @ViewChild(OtherChangeDir) otherDir !: OtherChangeDir;
+ @ViewChild(ButtonToggle, {static: false}) buttonToggle !: ButtonToggle;
+ @ViewChild(OtherChangeDir, {static: false}) otherDir !: OtherChangeDir;
change = true;
onChange() { counter++; }
diff --git a/packages/core/test/acceptance/pipe_spec.ts b/packages/core/test/acceptance/pipe_spec.ts
index a5b5c8c48e..56efdd827c 100644
--- a/packages/core/test/acceptance/pipe_spec.ts
+++ b/packages/core/test/acceptance/pipe_spec.ts
@@ -70,7 +70,7 @@ describe('pipe', () => {
template: ``,
})
class App {
- @ViewChild(Dir) directive !: Dir;
+ @ViewChild(Dir, {static: false}) directive !: Dir;
}
TestBed.configureTestingModule({declarations: [App, DoublePipe, Dir]});
diff --git a/packages/core/test/acceptance/template_ref_spec.ts b/packages/core/test/acceptance/template_ref_spec.ts
index 7184479bad..447f893876 100644
--- a/packages/core/test/acceptance/template_ref_spec.ts
+++ b/packages/core/test/acceptance/template_ref_spec.ts
@@ -25,7 +25,7 @@ describe('TemplateRef', () => {
exportAs: 'menuContent'
})
class MenuContent {
- @ViewChild(TemplateRef) template !: TemplateRef;
+ @ViewChild(TemplateRef, {static: true}) template !: TemplateRef;
}
@Component({
@@ -37,7 +37,7 @@ describe('TemplateRef', () => {
`
})
class App {
- @ViewChild(MenuContent) content !: MenuContent;
+ @ViewChild(MenuContent, {static: false}) content !: MenuContent;
constructor(public viewContainerRef: ViewContainerRef) {}
}
@@ -65,7 +65,7 @@ describe('TemplateRef', () => {
`
})
class App {
- @ViewChild('templateRef')
+ @ViewChild('templateRef', {static: true})
templateRef !: TemplateRef;
}
@@ -94,7 +94,7 @@ describe('TemplateRef', () => {
`
})
class App {
- @ViewChild('templateRef')
+ @ViewChild('templateRef', {static: true})
templateRef !: TemplateRef;
}
@@ -120,7 +120,7 @@ describe('TemplateRef', () => {
`
})
class App {
- @ViewChild('templateRef')
+ @ViewChild('templateRef', {static: true})
templateRef !: TemplateRef;
}
@@ -149,7 +149,7 @@ describe('TemplateRef', () => {
`
})
class App {
- @ViewChild('templateRef')
+ @ViewChild('templateRef', {static: true})
templateRef !: TemplateRef;
}
diff --git a/packages/core/test/acceptance/view_container_ref_spec.ts b/packages/core/test/acceptance/view_container_ref_spec.ts
index ca428508b4..45d4a5d10f 100644
--- a/packages/core/test/acceptance/view_container_ref_spec.ts
+++ b/packages/core/test/acceptance/view_container_ref_spec.ts
@@ -1770,7 +1770,7 @@ class ViewContainerRefComp {
`
})
class ViewContainerRefApp {
- @ViewChild(ViewContainerRefComp) vcrComp !: ViewContainerRefComp;
+ @ViewChild(ViewContainerRefComp, {static: false}) vcrComp !: ViewContainerRefComp;
}
@Directive({selector: '[structDir]'})
@@ -1803,7 +1803,7 @@ class ConstructorDir {
`
})
class ConstructorApp {
- @ViewChild('foo') foo !: ElementRef;
+ @ViewChild('foo', {static: true}) foo !: ElementRef;
}
@Component({
@@ -1815,5 +1815,5 @@ class ConstructorApp {
`
})
class ConstructorAppWithQueries {
- @ViewChild('foo') foo !: TemplateRef;
+ @ViewChild('foo', {static: true}) foo !: TemplateRef;
}
diff --git a/packages/core/test/animation/animation_integration_spec.ts b/packages/core/test/animation/animation_integration_spec.ts
index 590c254b17..809464e825 100644
--- a/packages/core/test/animation/animation_integration_spec.ts
+++ b/packages/core/test/animation/animation_integration_spec.ts
@@ -345,7 +345,7 @@ const DEFAULT_COMPONENT_ID = '1';
]
})
class Cmp {
- @ViewChild('element')
+ @ViewChild('element', {static: false})
element: any;
exp: any = '';
}
@@ -1433,7 +1433,7 @@ const DEFAULT_COMPONENT_ID = '1';
])]
})
class Cmp {
- @ViewChild('green') public element: any;
+ @ViewChild('green', {static: false}) public element: any;
}
TestBed.configureTestingModule({declarations: [Cmp]});
@@ -1770,7 +1770,7 @@ const DEFAULT_COMPONENT_ID = '1';
class Cmp {
public exp: any;
- @ViewChild('parent') public parentElement: any;
+ @ViewChild('parent', {static: false}) public parentElement: any;
}
TestBed.configureTestingModule({declarations: [Cmp]});
@@ -1824,9 +1824,9 @@ const DEFAULT_COMPONENT_ID = '1';
public exp1: any;
public exp2: any;
- @ViewChild('parent') public parent: any;
+ @ViewChild('parent', {static: false}) public parent: any;
- @ViewChild('child') public child: any;
+ @ViewChild('child', {static: false}) public child: any;
}
TestBed.configureTestingModule({declarations: [Cmp]});
@@ -1881,11 +1881,11 @@ const DEFAULT_COMPONENT_ID = '1';
public exp1: any;
public exp2: any;
- @ViewChild('parent') public parent: any;
+ @ViewChild('parent', {static: false}) public parent: any;
- @ViewChild('child1') public child1Elm: any;
+ @ViewChild('child1', {static: false}) public child1Elm: any;
- @ViewChild('child2') public child2Elm: any;
+ @ViewChild('child2', {static: false}) public child2Elm: any;
}
TestBed.configureTestingModule({declarations: [Cmp]});
@@ -2240,7 +2240,7 @@ const DEFAULT_COMPONENT_ID = '1';
[transition(':enter', [style({opacity: 0}), animate('1s', style({opacity: 1}))])])]
})
class OuterCmp {
- @ViewChild('inner') public inner: any;
+ @ViewChild('inner', {static: false}) public inner: any;
public exp: any = null;
update() { this.exp = 'go'; }
@@ -3073,7 +3073,7 @@ const DEFAULT_COMPONENT_ID = '1';
exp: any = false;
disableExp = false;
- @ViewChild('elm') public element: any;
+ @ViewChild('elm', {static: true}) public element: any;
}
TestBed.configureTestingModule({declarations: [Cmp]});
@@ -3231,7 +3231,7 @@ const DEFAULT_COMPONENT_ID = '1';
]
})
class Cmp {
- @ViewChild('parent') public parentElm: any;
+ @ViewChild('parent', {static: false}) public parentElm: any;
disableExp = false;
exp = false;
}
@@ -3322,7 +3322,7 @@ const DEFAULT_COMPONENT_ID = '1';
`
})
class ParentCmp {
- @ViewChild('child') public child: ChildCmp|null = null;
+ @ViewChild('child', {static: false}) public child: ChildCmp|null = null;
disableExp = false;
}
@@ -3438,7 +3438,7 @@ const DEFAULT_COMPONENT_ID = '1';
`
})
class Cmp {
- @ViewChild('container') public container: any;
+ @ViewChild('container', {static: false}) public container: any;
disableExp = false;
exp = '';
@@ -3661,7 +3661,7 @@ const DEFAULT_COMPONENT_ID = '1';
});
modifiedInIvy('FW-952 - Error recovery is handled differently in Ivy than VE')
- .it('should continue to clean up DOM-related animation artificats even if a compiler-level error is thrown midway',
+ .it('should continue to clean up DOM-related animation artifacts even if a compiler-level error is thrown midway',
() => {
@Component({
selector: 'if-cmp',
@@ -3684,7 +3684,7 @@ const DEFAULT_COMPONENT_ID = '1';
class Cmp {
exp: any = false;
- @ViewChild('contents') public contents: any;
+ @ViewChild('contents', {static: true}) public contents: any;
}
TestBed.configureTestingModule({declarations: [Cmp]});
diff --git a/packages/core/test/animation/animation_query_integration_spec.ts b/packages/core/test/animation/animation_query_integration_spec.ts
index 6a4a339765..9ee2dfc0da 100644
--- a/packages/core/test/animation/animation_query_integration_spec.ts
+++ b/packages/core/test/animation/animation_query_integration_spec.ts
@@ -14,7 +14,6 @@ import {CommonModule} from '@angular/common';
import {Component, HostBinding, ViewChild} from '@angular/core';
import {TestBed, fakeAsync, flushMicrotasks} from '@angular/core/testing';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
-import {ivyEnabled} from '@angular/private/testing';
import {HostListener} from '../../src/metadata/directives';
@@ -888,7 +887,7 @@ import {HostListener} from '../../src/metadata/directives';
]
})
class Cmp {
- @ViewChild('container') public container: any;
+ @ViewChild('container', {static: false}) public container: any;
public items: any[] = [];
}
@@ -1202,9 +1201,9 @@ import {HostListener} from '../../src/metadata/directives';
public exp1: any = '';
public exp2: any = true;
- @ViewChild('ancestor') public ancestorElm: any;
+ @ViewChild('ancestor', {static: false}) public ancestorElm: any;
- @ViewChild('parent') public parentElm: any;
+ @ViewChild('parent', {static: false}) public parentElm: any;
}
TestBed.configureTestingModule({declarations: [Cmp]});
@@ -1281,9 +1280,9 @@ import {HostListener} from '../../src/metadata/directives';
public exp2: any = '';
public parentExp: any = true;
- @ViewChild('ancestor') public ancestorElm: any;
+ @ViewChild('ancestor', {static: false}) public ancestorElm: any;
- @ViewChild('parent') public parentElm: any;
+ @ViewChild('parent', {static: false}) public parentElm: any;
}
TestBed.configureTestingModule({declarations: [Cmp]});
@@ -1637,7 +1636,7 @@ import {HostListener} from '../../src/metadata/directives';
class ParentCmp {
public exp: any;
- @ViewChild('child') public child: any;
+ @ViewChild('child', {static: false}) public child: any;
}
@Component({
@@ -1686,7 +1685,7 @@ import {HostListener} from '../../src/metadata/directives';
class ParentCmp {
public exp: any;
- @ViewChild('child') public child: any;
+ @ViewChild('child', {static: true}) public child: any;
}
@Component({
@@ -1705,10 +1704,6 @@ import {HostListener} from '../../src/metadata/directives';
const fixture = TestBed.createComponent(ParentCmp);
const cmp = fixture.componentInstance;
- // In Ivy, change detection needs to run before the ViewQuery for cmp.child will resolve.
- // Keeping this test enabled since we still want to test the animation logic in Ivy.
- if (ivyEnabled) fixture.detectChanges();
-
cmp.child.items = [4, 5, 6];
fixture.detectChanges();
@@ -1853,9 +1848,9 @@ import {HostListener} from '../../src/metadata/directives';
public exp1: any;
public exp2: any;
- @ViewChild('parent') public elm1: any;
+ @ViewChild('parent', {static: false}) public elm1: any;
- @ViewChild('child') public elm2: any;
+ @ViewChild('child', {static: false}) public elm2: any;
}
TestBed.configureTestingModule({declarations: [Cmp]});
@@ -1915,7 +1910,7 @@ import {HostListener} from '../../src/metadata/directives';
public exp: any;
public items: any[] = [0, 1, 2, 3, 4];
- @ViewChild('parent') public elm: any;
+ @ViewChild('parent', {static: false}) public elm: any;
}
TestBed.configureTestingModule({declarations: [Cmp]});
@@ -1985,7 +1980,7 @@ import {HostListener} from '../../src/metadata/directives';
public exp: any;
public items: any[] = [0, 1, 2, 3, 4];
- @ViewChild('parent') public elm: any;
+ @ViewChild('parent', {static: false}) public elm: any;
}
TestBed.configureTestingModule({declarations: [Cmp]});
@@ -2038,7 +2033,7 @@ import {HostListener} from '../../src/metadata/directives';
public exp1: any;
public exp2: any;
- @ViewChild('parent') public elm: any;
+ @ViewChild('parent', {static: false}) public elm: any;
}
TestBed.configureTestingModule({declarations: [Cmp]});
@@ -2108,7 +2103,7 @@ import {HostListener} from '../../src/metadata/directives';
public exp1: any;
public exp2: any;
- @ViewChild('parent') public elm: any;
+ @ViewChild('parent', {static: false}) public elm: any;
}
TestBed.configureTestingModule({declarations: [Cmp]});
@@ -2161,7 +2156,7 @@ import {HostListener} from '../../src/metadata/directives';
public exp1: any;
public exp2: any;
- @ViewChild('parent') public elm: any;
+ @ViewChild('parent', {static: false}) public elm: any;
}
TestBed.configureTestingModule({declarations: [Cmp]});
@@ -2213,7 +2208,7 @@ import {HostListener} from '../../src/metadata/directives';
public exp1: any;
public exp2: any;
- @ViewChild('parent') public elm: any;
+ @ViewChild('parent', {static: false}) public elm: any;
}
TestBed.configureTestingModule({declarations: [Cmp]});
@@ -2262,7 +2257,7 @@ import {HostListener} from '../../src/metadata/directives';
})
class ParentCmp {
public exp: boolean = true;
- @ViewChild('child') public childElm: any;
+ @ViewChild('child', {static: false}) public childElm: any;
public childEvent: any;
@@ -2698,7 +2693,7 @@ import {HostListener} from '../../src/metadata/directives';
class ParentCmp {
public exp: any;
- @ViewChild('child') public childCmp: any;
+ @ViewChild('child', {static: false}) public childCmp: any;
}
@Component({
@@ -2762,7 +2757,7 @@ import {HostListener} from '../../src/metadata/directives';
`
})
class ParentCmp {
- @ViewChild('child') public childCmp: any;
+ @ViewChild('child', {static: false}) public childCmp: any;
public exp: any;
public log: string[] = [];
@@ -2940,7 +2935,7 @@ import {HostListener} from '../../src/metadata/directives';
class ParentCmp {
public exp: any;
- @ViewChild('child') public childCmp: any;
+ @ViewChild('child', {static: false}) public childCmp: any;
}
@Component({
@@ -3018,13 +3013,13 @@ import {HostListener} from '../../src/metadata/directives';
class ParentCmp {
public exp: any;
- @ViewChild('child') public innerCmp: any;
+ @ViewChild('child', {static: false}) public innerCmp: any;
}
@Component(
{selector: 'child-cmp', template: ''})
class ChildCmp {
- @ViewChild('grandchild') public innerCmp: any;
+ @ViewChild('grandchild', {static: false}) public innerCmp: any;
}
@Component({
diff --git a/packages/core/test/animation/animations_with_css_keyframes_animations_integration_spec.ts b/packages/core/test/animation/animations_with_css_keyframes_animations_integration_spec.ts
index 150b68d96f..5e6baa888d 100644
--- a/packages/core/test/animation/animations_with_css_keyframes_animations_integration_spec.ts
+++ b/packages/core/test/animation/animations_with_css_keyframes_animations_integration_spec.ts
@@ -11,7 +11,6 @@ import {AnimationGroupPlayer} from '@angular/animations/src/players/animation_gr
import {Component, ViewChild} from '@angular/core';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {browserDetection} from '@angular/platform-browser/testing/src/browser_util';
-import {ivyEnabled} from '@angular/private/testing';
import {TestBed} from '../../testing';
@@ -166,7 +165,7 @@ import {TestBed} from '../../testing';
]
})
class Cmp {
- @ViewChild('elm') public element: any;
+ @ViewChild('elm', {static: false}) public element: any;
public myAnimationExp = '';
}
@@ -217,7 +216,7 @@ import {TestBed} from '../../testing';
]
})
class Cmp {
- @ViewChild('elm') public element: any;
+ @ViewChild('elm', {static: false}) public element: any;
public myAnimationExp = '';
}
@@ -280,7 +279,7 @@ import {TestBed} from '../../testing';
]
})
class Cmp {
- @ViewChild('elm') public element: any;
+ @ViewChild('elm', {static: true}) public element: any;
public myAnimationExp = '';
}
@@ -291,10 +290,6 @@ import {TestBed} from '../../testing';
const fixture = TestBed.createComponent(Cmp);
const cmp = fixture.componentInstance;
- // In Ivy, change detection needs to run before the ViewQuery for cmp.element will resolve.
- // Keeping this test enabled since we still want to test the animation logic in Ivy.
- if (ivyEnabled) fixture.detectChanges();
-
const elm = cmp.element.nativeElement;
const foo = elm.querySelector('.foo') as HTMLElement;
@@ -332,7 +327,7 @@ import {TestBed} from '../../testing';
]
})
class Cmp {
- @ViewChild('elm') public element: any;
+ @ViewChild('elm', {static: true}) public element: any;
public myAnimationExp = '';
}
@@ -343,10 +338,6 @@ import {TestBed} from '../../testing';
const fixture = TestBed.createComponent(Cmp);
const cmp = fixture.componentInstance;
- // In Ivy, change detection needs to run before the ViewQuery for cmp.element will resolve.
- // Keeping this test enabled since we still want to test the animation logic in Ivy.
- if (ivyEnabled) fixture.detectChanges();
-
const elm = cmp.element.nativeElement;
expect(elm.style.getPropertyValue('display')).toEqual('table');
expect(elm.style.getPropertyValue('position')).toEqual('fixed');
diff --git a/packages/core/test/animation/animations_with_web_animations_integration_spec.ts b/packages/core/test/animation/animations_with_web_animations_integration_spec.ts
index 7096a28b8e..f21c76dc53 100644
--- a/packages/core/test/animation/animations_with_web_animations_integration_spec.ts
+++ b/packages/core/test/animation/animations_with_web_animations_integration_spec.ts
@@ -479,7 +479,7 @@ import {ivyEnabled} from '@angular/private/testing';
]
})
class Cmp {
- @ViewChild('elm') public element: any;
+ @ViewChild('elm', {static: true}) public element: any;
public myAnimationExp = '';
}
@@ -490,10 +490,6 @@ import {ivyEnabled} from '@angular/private/testing';
const fixture = TestBed.createComponent(Cmp);
const cmp = fixture.componentInstance;
- // In Ivy, change detection needs to run before the ViewQuery for cmp.element will resolve.
- // Keeping this test enabled since we still want to test the animation logic in Ivy.
- if (ivyEnabled) fixture.detectChanges();
-
const elm = cmp.element.nativeElement;
expect(elm.style.getPropertyValue('display')).toEqual('table');
expect(elm.style.getPropertyValue('position')).toEqual('fixed');
diff --git a/packages/core/test/application_ref_spec.ts b/packages/core/test/application_ref_spec.ts
index 8a56680ec3..571ad7b111 100644
--- a/packages/core/test/application_ref_spec.ts
+++ b/packages/core/test/application_ref_spec.ts
@@ -16,7 +16,6 @@ import {BrowserModule} from '@angular/platform-browser';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util';
import {expect} from '@angular/platform-browser/testing/src/matchers';
-import {ivyEnabled} from '@angular/private/testing';
import {NoopNgZone} from '../src/zone/ng_zone';
import {ComponentFixtureNoNgZone, TestBed, async, inject, withModule} from '../testing';
@@ -386,14 +385,14 @@ class SomeComponent {
@Component({template: ''})
class ContainerComp {
// TODO(issue/24571): remove '!'.
- @ViewChild('vc', {read: ViewContainerRef})
+ @ViewChild('vc', {read: ViewContainerRef, static: false})
vc !: ViewContainerRef;
}
@Component({template: 'Dynamic content'})
class EmbeddedViewComp {
// TODO(issue/24571): remove '!'.
- @ViewChild(TemplateRef)
+ @ViewChild(TemplateRef, {static: true})
tplRef !: TemplateRef