diff --git a/packages/core/test/render3/exports_spec.ts b/packages/core/test/render3/exports_spec.ts
index 7638e0b1a1..c6d0ac0597 100644
--- a/packages/core/test/render3/exports_spec.ts
+++ b/packages/core/test/render3/exports_spec.ts
@@ -17,7 +17,7 @@ describe('exports', () => {
/** {{ myInput.value }} */
function Template(ctx: any, cm: boolean) {
if (cm) {
- elementStart(0, 'input', ['value', 'one']);
+ elementStart(0, 'input', ['value', 'one'], null, ['myInput', '']);
elementEnd();
text(1);
}
@@ -33,7 +33,7 @@ describe('exports', () => {
/** {{ myComp.name }} */
function Template(ctx: any, cm: boolean) {
if (cm) {
- elementStart(0, MyComponent);
+ elementStart(0, MyComponent, null, null, ['myComp', '']);
elementEnd();
text(2);
}
@@ -78,7 +78,7 @@ describe('exports', () => {
/**
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
- elementStart(0, MyComponent);
+ elementStart(0, MyComponent, null, null, ['myComp', '']);
elementEnd();
elementStart(2, 'div', null, [MyDir]);
elementEnd();
@@ -95,7 +95,7 @@ describe('exports', () => {
/** {{ myDir.name }} */
function Template(ctx: any, cm: boolean) {
if (cm) {
- elementStart(0, 'div', null, [SomeDir]);
+ elementStart(0, 'div', null, [SomeDir], ['myDir', 'someDir']);
elementEnd();
text(2);
}
@@ -116,7 +116,7 @@ describe('exports', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
text(0);
- elementStart(1, 'input', ['value', 'one']);
+ elementStart(1, 'input', ['value', 'one'], null, ['myInput', '']);
elementEnd();
}
let myInput = elementStart(1);
@@ -133,7 +133,7 @@ describe('exports', () => {
if (cm) {
elementStart(0, 'div');
elementEnd();
- elementStart(1, 'input', ['value', 'one']);
+ elementStart(1, 'input', ['value', 'one'], null, ['myInput', '']);
elementEnd();
}
let myInput = elementStart(1);
@@ -149,7 +149,7 @@ describe('exports', () => {
if (cm) {
elementStart(0, 'div');
elementEnd();
- elementStart(1, 'input', ['value', 'one']);
+ elementStart(1, 'input', ['value', 'one'], null, ['myInput', '']);
elementEnd();
}
let myInput = elementStart(1);
@@ -165,7 +165,7 @@ describe('exports', () => {
if (cm) {
elementStart(0, 'div');
elementEnd();
- elementStart(1, 'input', ['type', 'checkbox', 'checked', 'true']);
+ elementStart(1, 'input', ['type', 'checkbox', 'checked', 'true'], null, ['myInput', '']);
elementEnd();
}
let myInput = elementStart(1);
@@ -206,7 +206,7 @@ describe('exports', () => {
if (cm) {
elementStart(0, 'div', null, [MyDir]);
elementEnd();
- elementStart(2, MyComponent);
+ elementStart(2, MyComponent, null, null, ['myComp', '']);
elementEnd();
}
elementProperty(0, 'myDir', bind(load(3)));
@@ -223,9 +223,9 @@ describe('exports', () => {
if (cm) {
text(0);
text(1);
- elementStart(2, MyComponent);
+ elementStart(2, MyComponent, null, null, ['myComp', '']);
elementEnd();
- elementStart(4, 'input', ['value', 'one']);
+ elementStart(4, 'input', ['value', 'one'], null, ['myInput', '']);
elementEnd();
}
let myInput = elementStart(4);
@@ -265,7 +265,7 @@ describe('exports', () => {
{
if (cm1) {
text(0);
- elementStart(1, 'input', ['value', 'one']);
+ elementStart(1, 'input', ['value', 'one'], null, ['myInput', '']);
elementEnd();
}
let myInput = elementStart(1);
diff --git a/packages/core/test/render3/query_spec.ts b/packages/core/test/render3/query_spec.ts
index f3cdb380e6..d58dd4af04 100644
--- a/packages/core/test/render3/query_spec.ts
+++ b/packages/core/test/render3/query_spec.ts
@@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {QUERY_READ_CONTAINER_REF, QUERY_READ_ELEMENT_REF, QUERY_READ_FROM_NODE, QUERY_READ_TEMPLATE_REF} from '../../src/render3/di';
-import {QueryList, detectChanges} from '../../src/render3/index';
+import {QueryList, detectChanges, defineComponent} from '../../src/render3/index';
import {container, containerRefreshEnd, containerRefreshStart, elementEnd, elementStart, embeddedViewEnd, embeddedViewStart, load} from '../../src/render3/instructions';
import {query, queryRefresh} from '../../src/render3/query';
@@ -372,7 +372,7 @@ describe('query', () => {
let childInstance;
/**
- *
+ *
* class Cmpt {
* @ViewChildren('foo') query;
* }
@@ -394,6 +394,41 @@ describe('query', () => {
expect(qList.first).toBe(childInstance);
});
+ it('should read component instance with explicit exportAs', () => {
+ let childInstance: Child;
+
+ class Child {
+ static ngComponentDef = defineComponent({
+ type: Child,
+ tag: 'child',
+ factory: () => childInstance = new Child(),
+ template: (ctx: Child, cm: boolean) => {},
+ exportAs: 'child'
+ });
+ }
+
+ /**
+ *
+ * class Cmpt {
+ * @ViewChildren('foo') query;
+ * }
+ */
+ const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
+ let tmp: any;
+ if (cm) {
+ query(0, ['foo'], true, QUERY_READ_FROM_NODE);
+ elementStart(1, Child, null, null, ['foo', 'child']);
+ elementEnd();
+ }
+ queryRefresh(tmp = load>(0)) && (ctx.query = tmp as QueryList);
+ });
+
+ const cmptInstance = renderComponent(Cmpt);
+ const qList = (cmptInstance.query as QueryList);
+ expect(qList.length).toBe(1);
+ expect(qList.first).toBe(childInstance !);
+ });
+
it('should read directive instance if element queried for has an exported directive with a matching name',
() => {
const Child = createDirective({exportAs: 'child'});
@@ -454,7 +489,7 @@ describe('query', () => {
expect(qList.last).toBe(child2Instance);
});
- it('should match match on exported directive name and read a requested token', () => {
+ it('should match on exported directive name and read a requested token', () => {
const Child = createDirective({exportAs: 'child'});
let div;