refactor(ivy): use long instruction format in tests (#22055)

PR Close #22055
This commit is contained in:
Victor Berchet 2018-02-06 16:11:20 -08:00 committed by Miško Hevery
parent 16dada28f5
commit 8feb8e5408
19 changed files with 1924 additions and 1874 deletions

View File

@ -10,7 +10,6 @@ import {QueryList} from '../../linker';
import {Type} from '../../type';
import {LNode} from './node';
/** Used for tracking queries (e.g. ViewChild, ContentChild). */
export interface LQueries {
/**

View File

@ -6,7 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {C, E, T, V, cR, cr, defineComponent, e, v} from '../../src/render3/index';
import {defineComponent} from '../../src/render3/index';
import {container, containerRefreshEnd, containerRefreshStart, elementEnd, elementStart, text, viewEnd, viewStart} from '../../src/render3/instructions';
import {document, renderComponent} from './render_util';
@ -36,23 +37,23 @@ describe('iv perf test', () => {
tag: 'div',
template: function Template(ctx: any, cm: any) {
if (cm) {
C(0);
container(0);
}
cR(0);
containerRefreshStart(0);
{
for (let i = 0; i < count; i++) {
let cm0 = V(0);
let cm0 = viewStart(0);
{
if (cm0) {
E(0, 'div');
T(1, '-');
e();
elementStart(0, 'div');
text(1, '-');
elementEnd();
}
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
},
factory: () => new Component
});

View File

@ -8,7 +8,8 @@
import {NgForOfContext} from '@angular/common';
import {C, E, T, b, cR, cr, defineComponent, e, p, r, t} from '../../src/render3/index';
import {defineComponent} from '../../src/render3/index';
import {bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementProperty, elementStart, text, textBinding} from '../../src/render3/instructions';
import {NgForOf} from './common_with_def';
import {renderComponent, toHtml} from './render_util';
@ -28,22 +29,22 @@ describe('@angular/common integration', () => {
// </ul>
template: (myApp: MyApp, cm: boolean) => {
if (cm) {
E(0, 'ul');
{ C(1, [NgForOf], liTemplate); }
e();
elementStart(0, 'ul');
{ container(1, [NgForOf], liTemplate); }
elementEnd();
}
p(1, 'ngForOf', b(myApp.items));
cR(1);
r(2, 0);
cr();
elementProperty(1, 'ngForOf', bind(myApp.items));
containerRefreshStart(1);
componentRefresh(2, 0);
containerRefreshEnd();
function liTemplate(row: NgForOfContext<string>, cm: boolean) {
if (cm) {
E(0, 'li');
{ T(1); }
e();
elementStart(0, 'li');
{ text(1); }
elementEnd();
}
t(1, b(row.$implicit));
textBinding(1, bind(row.$implicit));
}
}
});

View File

@ -10,7 +10,8 @@ import {NgForOf as NgForOfDef} from '@angular/common';
import {IterableDiffers} from '@angular/core';
import {defaultIterableDiffers} from '../../src/change_detection/change_detection';
import {DirectiveType, InjectFlags, NgOnChangesFeature, defineDirective, inject, injectTemplateRef, injectViewContainerRef, m} from '../../src/render3/index';
import {DirectiveType, InjectFlags, NgOnChangesFeature, defineDirective, inject, injectTemplateRef, injectViewContainerRef} from '../../src/render3/index';
import {memory} from '../../src/render3/instructions';
export const NgForOf: DirectiveType<NgForOfDef<any>> = NgForOfDef as any;

View File

@ -7,7 +7,8 @@
*/
import {ViewEncapsulation} from '../../src/core';
import {C, E, T, V, b, cR, cr, defineComponent, e, markDirty, p, r, t, v} from '../../src/render3/index';
import {defineComponent, markDirty} from '../../src/render3/index';
import {bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementProperty, elementStart, text, textBinding, viewEnd, viewStart} from '../../src/render3/instructions';
import {createRendererType2} from '../../src/view/index';
import {getRendererFactory2} from './imported_renderer2';
@ -24,9 +25,9 @@ describe('component', () => {
tag: 'counter',
template: function(ctx: CounterComponent, cm: boolean) {
if (cm) {
T(0);
text(0);
}
t(0, b(ctx.count));
textBinding(0, bind(ctx.count));
},
factory: () => new CounterComponent,
inputs: {count: 'count'},
@ -63,22 +64,22 @@ describe('component with a container', () => {
function showItems(ctx: {items: string[]}, cm: boolean) {
if (cm) {
C(0);
container(0);
}
cR(0);
containerRefreshStart(0);
{
for (const item of ctx.items) {
const cm0 = V(0);
const cm0 = viewStart(0);
{
if (cm0) {
T(0);
text(0);
}
t(0, b(item));
textBinding(0, bind(item));
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
class WrapperComponent {
@ -88,15 +89,15 @@ describe('component with a container', () => {
tag: 'wrapper',
template: function ChildComponentTemplate(ctx: {items: string[]}, cm: boolean) {
if (cm) {
C(0);
container(0);
}
cR(0);
containerRefreshStart(0);
{
const cm0 = V(0);
const cm0 = viewStart(0);
{ showItems({items: ctx.items}, cm0); }
v();
viewEnd();
}
cr();
containerRefreshEnd();
},
factory: () => new WrapperComponent,
inputs: {items: 'items'}
@ -105,12 +106,12 @@ describe('component with a container', () => {
function template(ctx: {items: string[]}, cm: boolean) {
if (cm) {
E(0, WrapperComponent);
e();
elementStart(0, WrapperComponent);
elementEnd();
}
p(0, 'items', b(ctx.items));
elementProperty(0, 'items', bind(ctx.items));
WrapperComponent.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
it('should re-render on input change', () => {
@ -132,11 +133,11 @@ describe('encapsulation', () => {
tag: 'wrapper',
template: function(ctx: WrapperComponent, cm: boolean) {
if (cm) {
E(0, EncapsulatedComponent);
e();
elementStart(0, EncapsulatedComponent);
elementEnd();
}
EncapsulatedComponent.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
},
factory: () => new WrapperComponent,
});
@ -148,12 +149,12 @@ describe('encapsulation', () => {
tag: 'encapsulated',
template: function(ctx: EncapsulatedComponent, cm: boolean) {
if (cm) {
T(0, 'foo');
E(1, LeafComponent);
e();
text(0, 'foo');
elementStart(1, LeafComponent);
elementEnd();
}
LeafComponent.ngComponentDef.h(2, 1);
r(2, 1);
componentRefresh(2, 1);
},
factory: () => new EncapsulatedComponent,
rendererType:
@ -167,9 +168,9 @@ describe('encapsulation', () => {
tag: 'leaf',
template: function(ctx: LeafComponent, cm: boolean) {
if (cm) {
E(0, 'span');
{ T(1, 'bar'); }
e();
elementStart(0, 'span');
{ text(1, 'bar'); }
elementEnd();
}
},
factory: () => new LeafComponent,
@ -197,11 +198,11 @@ describe('encapsulation', () => {
tag: 'wrapper',
template: function(ctx: WrapperComponentWith, cm: boolean) {
if (cm) {
E(0, LeafComponentwith);
e();
elementStart(0, LeafComponentwith);
elementEnd();
}
LeafComponentwith.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
},
factory: () => new WrapperComponentWith,
rendererType:
@ -215,9 +216,9 @@ describe('encapsulation', () => {
tag: 'leaf',
template: function(ctx: LeafComponentwith, cm: boolean) {
if (cm) {
E(0, 'span');
{ T(1, 'bar'); }
e();
elementStart(0, 'span');
{ text(1, 'bar'); }
elementEnd();
}
},
factory: () => new LeafComponentwith,

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {C, E, T, V, b, cR, cr, e, t, v} from '../../src/render3/index';
import {bind, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementStart, text, textBinding, viewEnd, viewStart} from '../../src/render3/instructions';
import {renderToHtml} from './render_util';
@ -16,26 +16,26 @@ describe('JS control flow', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div');
{ C(1); }
e();
elementStart(0, 'div');
{ container(1); }
elementEnd();
}
cR(1);
containerRefreshStart(1);
{
if (ctx.condition) {
let cm1 = V(1);
let cm1 = viewStart(1);
{
if (cm1) {
E(0, 'span');
{ T(1); }
e();
elementStart(0, 'span');
{ text(1); }
elementEnd();
}
t(1, b(ctx.message));
textBinding(1, bind(ctx.message));
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
expect(renderToHtml(Template, ctx)).toEqual('<div><span>Hello</span></div>');
@ -64,38 +64,38 @@ describe('JS control flow', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div');
{ C(1); }
e();
elementStart(0, 'div');
{ container(1); }
elementEnd();
}
cR(1);
containerRefreshStart(1);
{
if (ctx.condition) {
let cm1 = V(1);
let cm1 = viewStart(1);
{
if (cm1) {
E(0, 'span');
{ C(1); }
e();
elementStart(0, 'span');
{ container(1); }
elementEnd();
}
cR(1);
containerRefreshStart(1);
{
if (ctx.condition2) {
let cm2 = V(2);
let cm2 = viewStart(2);
{
if (cm2) {
T(0, 'Hello');
text(0, 'Hello');
}
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
expect(renderToHtml(Template, ctx)).toEqual('<div><span>Hello</span></div>');
@ -128,37 +128,37 @@ describe('JS control flow', () => {
it('should work with containers with views as parents', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div');
{ T(1, 'hello'); }
e();
C(2);
elementStart(0, 'div');
{ text(1, 'hello'); }
elementEnd();
container(2);
}
cR(2);
containerRefreshStart(2);
{
if (ctx.condition1) {
let cm0 = V(0);
let cm0 = viewStart(0);
{
if (cm0) {
C(0);
container(0);
}
cR(0);
containerRefreshStart(0);
{
if (ctx.condition2) {
let cm0 = V(0);
let cm0 = viewStart(0);
{
if (cm0) {
T(0, 'world');
text(0, 'world');
}
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
expect(renderToHtml(Template, {condition1: true, condition2: true}))
@ -173,26 +173,26 @@ describe('JS control flow', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'ul');
{ C(1); }
e();
elementStart(0, 'ul');
{ container(1); }
elementEnd();
}
cR(1);
containerRefreshStart(1);
{
for (let i = 0; i < ctx.data.length; i++) {
let cm1 = V(1);
let cm1 = viewStart(1);
{
if (cm1) {
E(0, 'li');
{ T(1); }
e();
elementStart(0, 'li');
{ text(1); }
elementEnd();
}
t(1, b(ctx.data[i]));
textBinding(1, bind(ctx.data[i]));
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
expect(renderToHtml(Template, ctx)).toEqual('<ul><li>a</li><li>b</li><li>c</li></ul>');
@ -219,36 +219,36 @@ describe('JS control flow', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'ul');
{ C(1); }
e();
elementStart(0, 'ul');
{ container(1); }
elementEnd();
}
cR(1);
containerRefreshStart(1);
{
for (let i = 0; i < ctx.data[0].length; i++) {
let cm1 = V(1);
let cm1 = viewStart(1);
{
if (cm1) {
E(0, 'li');
{ C(1); }
e();
elementStart(0, 'li');
{ container(1); }
elementEnd();
}
cR(1);
containerRefreshStart(1);
{
ctx.data[1].forEach((value: string, ind: number) => {
if (V(2)) {
T(0);
if (viewStart(2)) {
text(0);
}
t(0, b(ctx.data[0][i] + value));
v();
textBinding(0, bind(ctx.data[0][i] + value));
viewEnd();
});
}
cr();
containerRefreshEnd();
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
expect(renderToHtml(Template, ctx)).toEqual('<ul><li>aman</li><li>bmbn</li><li>cmcn</li></ul>');
@ -274,43 +274,43 @@ describe('JS control flow', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div');
elementStart(0, 'div');
{
T(1, 'Before');
C(2);
T(3, 'After');
text(1, 'Before');
container(2);
text(3, 'After');
}
e();
elementEnd();
}
cR(2);
containerRefreshStart(2);
{
for (let i = 0; i < ctx.cafes.length; i++) {
let cm1 = V(1);
let cm1 = viewStart(1);
{
if (cm1) {
E(0, 'h2');
{ T(1); }
e();
C(2);
T(3, '-');
elementStart(0, 'h2');
{ text(1); }
elementEnd();
container(2);
text(3, '-');
}
t(1, b(ctx.cafes[i].name));
cR(2);
textBinding(1, bind(ctx.cafes[i].name));
containerRefreshStart(2);
{
for (let j = 0; j < ctx.cafes[i].entrees.length; j++) {
if (V(1)) {
T(0);
if (viewStart(1)) {
text(0);
}
t(0, b(ctx.cafes[i].entrees[j]));
v();
textBinding(0, bind(ctx.cafes[i].entrees[j]));
viewEnd();
}
}
cr();
containerRefreshEnd();
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
const ctx = {
@ -354,60 +354,60 @@ describe('JS control flow', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div');
elementStart(0, 'div');
{
T(1, 'Before');
C(2);
T(3, 'After');
text(1, 'Before');
container(2);
text(3, 'After');
}
e();
elementEnd();
}
cR(2);
containerRefreshStart(2);
{
for (let i = 0; i < ctx.cafes.length; i++) {
let cm1 = V(1);
let cm1 = viewStart(1);
{
if (cm1) {
E(0, 'h2');
{ T(1); }
e();
C(2);
T(3, '-');
elementStart(0, 'h2');
{ text(1); }
elementEnd();
container(2);
text(3, '-');
}
t(1, b(ctx.cafes[i].name));
cR(2);
textBinding(1, bind(ctx.cafes[i].name));
containerRefreshStart(2);
{
for (let j = 0; j < ctx.cafes[i].entrees.length; j++) {
let cm1 = V(1);
let cm1 = viewStart(1);
{
if (cm1) {
E(0, 'h3');
{ T(1); }
e();
C(2);
elementStart(0, 'h3');
{ text(1); }
elementEnd();
container(2);
}
t(1, b(ctx.cafes[i].entrees[j].name));
cR(2);
textBinding(1, bind(ctx.cafes[i].entrees[j].name));
containerRefreshStart(2);
{
for (let k = 0; k < ctx.cafes[i].entrees[j].foods.length; k++) {
if (V(1)) {
T(0);
if (viewStart(1)) {
text(0);
}
t(0, b(ctx.cafes[i].entrees[j].foods[k]));
v();
textBinding(0, bind(ctx.cafes[i].entrees[j].foods[k]));
viewEnd();
}
}
cr();
containerRefreshEnd();
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
const ctx = {
@ -444,35 +444,35 @@ describe('JS control flow', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div');
{ C(1); }
e();
elementStart(0, 'div');
{ container(1); }
elementEnd();
}
cR(1);
containerRefreshStart(1);
{
if (ctx.condition) {
let cm1 = V(1);
let cm1 = viewStart(1);
{
if (cm1) {
E(0, 'span');
{ T(1, 'Hello'); }
e();
elementStart(0, 'span');
{ text(1, 'Hello'); }
elementEnd();
}
}
v();
viewEnd();
} else {
let cm2 = V(2);
let cm2 = viewStart(2);
{
if (cm2) {
E(0, 'div');
{ T(1, 'Goodbye'); }
e();
elementStart(0, 'div');
{ text(1, 'Goodbye'); }
elementEnd();
}
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
expect(renderToHtml(Template, ctx)).toEqual('<div><span>Hello</span></div>');
@ -492,28 +492,28 @@ describe('JS for loop', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div');
{ C(1); }
e();
elementStart(0, 'div');
{ container(1); }
elementEnd();
}
cR(1);
containerRefreshStart(1);
{
for (let i = 0; i < ctx.data1.length; i++) {
if (V(1)) {
T(0);
if (viewStart(1)) {
text(0);
}
t(0, b(ctx.data1[i]));
v();
textBinding(0, bind(ctx.data1[i]));
viewEnd();
}
for (let j = 0; j < ctx.data2.length; j++) {
if (V(2)) {
T(0);
if (viewStart(2)) {
text(0);
}
t(0, b(ctx.data2[j]));
v();
textBinding(0, bind(ctx.data2[j]));
viewEnd();
}
}
cr();
containerRefreshEnd();
}
expect(renderToHtml(Template, ctx)).toEqual('<div>abc12</div>');
@ -536,38 +536,38 @@ describe('function calls', () => {
function spanify(ctx: {message: string | null}, cm: boolean) {
const message = ctx.message;
if (cm) {
E(0, 'span');
{ T(1); }
e();
elementStart(0, 'span');
{ text(1); }
elementEnd();
}
t(1, b(message));
textBinding(1, bind(message));
}
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div');
elementStart(0, 'div');
{
T(1, 'Before');
C(2);
C(3);
T(4, 'After');
text(1, 'Before');
container(2);
container(3);
text(4, 'After');
}
e();
elementEnd();
}
cR(2);
containerRefreshStart(2);
{
let cm0 = V(0);
let cm0 = viewStart(0);
{ spanify({message: ctx.data[0]}, cm0); }
v();
viewEnd();
}
cr();
cR(3);
containerRefreshEnd();
containerRefreshStart(3);
{
let cm0 = V(0);
let cm0 = viewStart(0);
{ spanify({message: ctx.data[1]}, cm0); }
v();
viewEnd();
}
cr();
containerRefreshEnd();
}
expect(renderToHtml(Template, ctx))

View File

@ -10,8 +10,8 @@ import {ElementRef, TemplateRef, ViewContainerRef} from '@angular/core';
import {defineComponent} from '../../src/render3/definition';
import {InjectFlags, bloomAdd, bloomFindPossibleInjector, getOrCreateNodeInjector} from '../../src/render3/di';
import {C, E, PublicFeature, T, V, b, b2, cR, cr, defineDirective, e, inject, injectElementRef, injectTemplateRef, injectViewContainerRef, m, t, v} from '../../src/render3/index';
import {createLNode, createLView, createTView, enterView, leaveView} from '../../src/render3/instructions';
import {PublicFeature, defineDirective, inject, injectElementRef, injectTemplateRef, injectViewContainerRef} from '../../src/render3/index';
import {bind, bind2, container, containerRefreshEnd, containerRefreshStart, createLNode, createLView, createTView, elementEnd, elementStart, enterView, leaveView, memory, text, textBinding, viewEnd, viewStart} from '../../src/render3/instructions';
import {LInjector} from '../../src/render3/interfaces/injector';
import {LNodeFlags} from '../../src/render3/interfaces/node';
@ -27,11 +27,11 @@ describe('di', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div', null, [Directive]);
{ T(2); }
e();
elementStart(0, 'div', null, [Directive]);
{ text(2); }
elementEnd();
}
t(2, b(m<Directive>(1).value));
textBinding(2, bind(memory<Directive>(1).value));
}
expect(renderToHtml(Template, {})).toEqual('<div>Created</div>');
@ -63,15 +63,15 @@ describe('di', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div', null, [DirectiveA]);
elementStart(0, 'div', null, [DirectiveA]);
{
E(2, 'span', null, [DirectiveB, DirectiveC]);
{ T(5); }
e();
elementStart(2, 'span', null, [DirectiveB, DirectiveC]);
{ text(5); }
elementEnd();
}
e();
elementEnd();
}
t(5, b(m<DirectiveC>(4).value));
textBinding(5, bind(memory<DirectiveC>(4).value));
}
expect(renderToHtml(Template, {})).toEqual('<div><span>AB</span></div>');
@ -105,11 +105,13 @@ describe('di', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div', null, [Directive, DirectiveSameInstance]);
{ T(3); }
e();
elementStart(0, 'div', null, [Directive, DirectiveSameInstance]);
{ text(3); }
elementEnd();
}
t(3, b2('', m<Directive>(1).value, '-', m<DirectiveSameInstance>(2).value, ''));
textBinding(
3,
bind2('', memory<Directive>(1).value, '-', memory<DirectiveSameInstance>(2).value, ''));
}
expect(renderToHtml(Template, {})).toEqual('<div>ElementRef-true</div>');
@ -144,10 +146,12 @@ describe('di', () => {
function Template(ctx: any, cm: any) {
if (cm) {
C(0, [Directive, DirectiveSameInstance], function() {});
T(3);
container(0, [Directive, DirectiveSameInstance], function() {});
text(3);
}
t(3, b2('', m<Directive>(1).value, '-', m<DirectiveSameInstance>(2).value, ''));
textBinding(
3,
bind2('', memory<Directive>(1).value, '-', memory<DirectiveSameInstance>(2).value, ''));
}
expect(renderToHtml(Template, {})).toEqual('TemplateRef-true');
@ -181,11 +185,13 @@ describe('di', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div', null, [Directive, DirectiveSameInstance]);
{ T(3); }
e();
elementStart(0, 'div', null, [Directive, DirectiveSameInstance]);
{ text(3); }
elementEnd();
}
t(3, b2('', m<Directive>(1).value, '-', m<DirectiveSameInstance>(2).value, ''));
textBinding(
3,
bind2('', memory<Directive>(1).value, '-', memory<DirectiveSameInstance>(2).value, ''));
}
expect(renderToHtml(Template, {})).toEqual('<div>ViewContainerRef-true</div>');
@ -285,21 +291,24 @@ describe('di', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div', null, [ParentDirective]);
{ C(2); }
e();
elementStart(0, 'div', null, [ParentDirective]);
{ container(2); }
elementEnd();
}
cR(2);
containerRefreshStart(2);
{
if (V(0)) {
E(0, 'span', null, [ChildDirective, Child2Directive]);
{ T(3); }
e();
if (viewStart(0)) {
elementStart(0, 'span', null, [ChildDirective, Child2Directive]);
{ text(3); }
elementEnd();
}
t(3, b2('', m<ChildDirective>(1).value, '-', m<Child2Directive>(2).value, ''));
v();
textBinding(
3,
bind2(
'', memory<ChildDirective>(1).value, '-', memory<Child2Directive>(2).value, ''));
viewEnd();
}
cr();
containerRefreshEnd();
}
expect(renderToHtml(Template, {})).toEqual('<div><span>ParentDirective-true</span></div>');

View File

@ -6,7 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {E, b, defineDirective, e, m, p, r} from '../../src/render3/index';
import {defineDirective} from '../../src/render3/index';
import {bind, componentRefresh, elementEnd, elementProperty, elementStart, memory} from '../../src/render3/instructions';
import {renderToHtml} from './render_util';
@ -23,18 +24,19 @@ describe('directive', () => {
type: Directive,
factory: () => directiveInstance = new Directive,
hostBindings: (directiveIndex: number, elementIndex: number) => {
p(elementIndex, 'className', b(m<Directive>(directiveIndex).klass));
elementProperty(
elementIndex, 'className', bind(memory<Directive>(directiveIndex).klass));
}
});
}
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'span', null, [Directive]);
e();
elementStart(0, 'span', null, [Directive]);
elementEnd();
}
Directive.ngDirectiveDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
expect(renderToHtml(Template, {})).toEqual('<span class="foo"></span>');

View File

@ -6,7 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {C, E, T, V, a, b, cR, cr, defineComponent, defineDirective, e, k, m, p, t, v} from '../../src/render3/index';
import {defineComponent, defineDirective} from '../../src/render3/index';
import {bind, container, containerRefreshEnd, containerRefreshStart, elementAttribute, elementClass, elementEnd, elementProperty, elementStart, memory, text, textBinding, viewEnd, viewStart} from '../../src/render3/instructions';
import {renderToHtml} from './render_util';
@ -16,12 +17,12 @@ describe('exports', () => {
/** <input value="one" #myInput> {{ myInput.value }} */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'input', ['value', 'one']);
e();
T(1);
elementStart(0, 'input', ['value', 'one']);
elementEnd();
text(1);
}
let myInput = E(0);
t(1, (myInput as any).value);
let myInput = elementStart(0);
textBinding(1, (myInput as any).value);
}
expect(renderToHtml(Template, {})).toEqual('<input value="one">one');
@ -32,11 +33,11 @@ describe('exports', () => {
/** <comp #myComp></comp> {{ myComp.name }} */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, MyComponent);
e();
T(2);
elementStart(0, MyComponent);
elementEnd();
text(2);
}
t(2, m<MyComponent>(1).name);
textBinding(2, memory<MyComponent>(1).name);
}
class MyComponent {
@ -77,12 +78,12 @@ describe('exports', () => {
/** <comp #myComp></comp> <div [myDir]="myComp"></div> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, MyComponent);
e();
E(2, 'div', null, [MyDir]);
e();
elementStart(0, MyComponent);
elementEnd();
elementStart(2, 'div', null, [MyDir]);
elementEnd();
}
p(2, 'myDir', b(m<MyComponent>(1)));
elementProperty(2, 'myDir', bind(memory<MyComponent>(1)));
}
renderToHtml(Template, {});
@ -94,11 +95,11 @@ describe('exports', () => {
/** <div someDir #myDir="someDir"></div> {{ myDir.name }} */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div', null, [SomeDir]);
e();
T(2);
elementStart(0, 'div', null, [SomeDir]);
elementEnd();
text(2);
}
t(2, m<SomeDir>(1).name);
textBinding(2, memory<SomeDir>(1).name);
}
class SomeDir {
@ -114,12 +115,12 @@ describe('exports', () => {
/** {{ myInput.value}} <input value="one" #myInput> */
function Template(ctx: any, cm: boolean) {
if (cm) {
T(0);
E(1, 'input', ['value', 'one']);
e();
text(0);
elementStart(1, 'input', ['value', 'one']);
elementEnd();
}
let myInput = E(1);
t(0, b((myInput as any).value));
let myInput = elementStart(1);
textBinding(0, bind((myInput as any).value));
}
expect(renderToHtml(Template, {})).toEqual('one<input value="one">');
@ -130,13 +131,13 @@ describe('exports', () => {
/** <div [title]="myInput.value"</div> <input value="one" #myInput> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div');
e();
E(1, 'input', ['value', 'one']);
e();
elementStart(0, 'div');
elementEnd();
elementStart(1, 'input', ['value', 'one']);
elementEnd();
}
let myInput = E(1);
p(0, 'title', b(myInput && (myInput as any).value));
let myInput = elementStart(1);
elementProperty(0, 'title', bind(myInput && (myInput as any).value));
}
expect(renderToHtml(Template, {})).toEqual('<div title="one"></div><input value="one">');
@ -146,13 +147,13 @@ describe('exports', () => {
/** <div [attr.aria-label]="myInput.value"</div> <input value="one" #myInput> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div');
e();
E(1, 'input', ['value', 'one']);
e();
elementStart(0, 'div');
elementEnd();
elementStart(1, 'input', ['value', 'one']);
elementEnd();
}
let myInput = E(1);
a(0, 'aria-label', b(myInput && (myInput as any).value));
let myInput = elementStart(1);
elementAttribute(0, 'aria-label', bind(myInput && (myInput as any).value));
}
expect(renderToHtml(Template, {})).toEqual('<div aria-label="one"></div><input value="one">');
@ -162,13 +163,13 @@ describe('exports', () => {
/** <div [class.red]="myInput.checked"</div> <input type="checkbox" checked #myInput> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div');
e();
E(1, 'input', ['type', 'checkbox', 'checked', 'true']);
e();
elementStart(0, 'div');
elementEnd();
elementStart(1, 'input', ['type', 'checkbox', 'checked', 'true']);
elementEnd();
}
let myInput = E(1);
k(0, 'red', b(myInput && (myInput as any).checked));
let myInput = elementStart(1);
elementClass(0, 'red', bind(myInput && (myInput as any).checked));
}
expect(renderToHtml(Template, {}))
@ -203,12 +204,12 @@ describe('exports', () => {
/** <div [myDir]="myComp"></div><comp #myComp></comp> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div', null, [MyDir]);
e();
E(2, MyComponent);
e();
elementStart(0, 'div', null, [MyDir]);
elementEnd();
elementStart(2, MyComponent);
elementEnd();
}
p(0, 'myDir', b(m<MyComponent>(3)));
elementProperty(0, 'myDir', bind(memory<MyComponent>(3)));
}
renderToHtml(Template, {});
@ -220,17 +221,17 @@ describe('exports', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
T(0);
T(1);
E(2, MyComponent);
e();
E(4, 'input', ['value', 'one']);
e();
text(0);
text(1);
elementStart(2, MyComponent);
elementEnd();
elementStart(4, 'input', ['value', 'one']);
elementEnd();
}
let myInput = E(4);
let myComp = m(3) as MyComponent;
t(0, b(myInput && (myInput as any).value));
t(1, b(myComp && myComp.name));
let myInput = elementStart(4);
let myComp = memory(3) as MyComponent;
textBinding(0, bind(myInput && (myInput as any).value));
textBinding(1, bind(myComp && myComp.name));
}
let myComponent: MyComponent;
@ -253,27 +254,27 @@ describe('exports', () => {
it('should work inside a view container', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div');
{ C(1); }
e();
elementStart(0, 'div');
{ container(1); }
elementEnd();
}
cR(1);
containerRefreshStart(1);
{
if (ctx.condition) {
let cm1 = V(1);
let cm1 = viewStart(1);
{
if (cm1) {
T(0);
E(1, 'input', ['value', 'one']);
e();
text(0);
elementStart(1, 'input', ['value', 'one']);
elementEnd();
}
let myInput = E(1);
t(0, b(myInput && (myInput as any).value));
let myInput = elementStart(1);
textBinding(0, bind(myInput && (myInput as any).value));
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
expect(renderToHtml(Template, {

View File

@ -6,8 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {C, E, NC, P, T, V, a, b, b1, b2, b3, b4, b5, b6, b7, b8, bV, cR, cr, defineComponent, e, k, m, p, pD, r, s, t, v} from '../../src/render3/index';
import {NO_CHANGE} from '../../src/render3/instructions';
import {defineComponent} from '../../src/render3/index';
import {NO_CHANGE, bind, bind1, bind2, bind3, bind4, bind5, bind6, bind7, bind8, bindV, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementAttribute, elementClass, elementEnd, elementProperty, elementStart, elementStyle, memory, projection, projectionDef, text, textBinding, viewEnd, viewStart} from '../../src/render3/instructions';
import {containerEl, renderToHtml} from './render_util';
@ -20,9 +20,9 @@ describe('render3 integration test', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'span', ['title', 'Hello']);
{ T(1, 'Greetings'); }
e();
elementStart(0, 'span', ['title', 'Hello']);
{ text(1, 'Greetings'); }
elementEnd();
}
}
});
@ -33,11 +33,11 @@ describe('render3 integration test', () => {
function Template(name: string, cm: boolean) {
if (cm) {
E(0, 'h1');
{ T(1); }
e();
elementStart(0, 'h1');
{ text(1); }
elementEnd();
}
t(1, b1('Hello, ', name, '!'));
textBinding(1, bind1('Hello, ', name, '!'));
}
});
});
@ -46,9 +46,9 @@ describe('render3 integration test', () => {
it('should render "undefined" as "" when used with `bind()`', () => {
function Template(name: string, cm: boolean) {
if (cm) {
T(0);
text(0);
}
t(0, b(name));
textBinding(0, bind(name));
}
expect(renderToHtml(Template, 'benoit')).toEqual('benoit');
@ -58,9 +58,9 @@ describe('render3 integration test', () => {
it('should render "null" as "" when used with `bind()`', () => {
function Template(name: string, cm: boolean) {
if (cm) {
T(0);
text(0);
}
t(0, b(name));
textBinding(0, bind(name));
}
expect(renderToHtml(Template, 'benoit')).toEqual('benoit');
@ -70,9 +70,9 @@ describe('render3 integration test', () => {
it('should support creation-time values in text nodes', () => {
function Template(value: string, cm: boolean) {
if (cm) {
T(0);
text(0);
}
t(0, cm ? value : NO_CHANGE);
textBinding(0, cm ? value : NO_CHANGE);
}
expect(renderToHtml(Template, 'once')).toEqual('once');
expect(renderToHtml(Template, 'twice')).toEqual('once');
@ -81,27 +81,32 @@ describe('render3 integration test', () => {
it('should support creation-time bindings in interpolations', () => {
function Template(v: string, cm: boolean) {
if (cm) {
T(0);
T(1);
T(2);
T(3);
T(4);
T(5);
T(6);
T(7);
T(8);
text(0);
text(1);
text(2);
text(3);
text(4);
text(5);
text(6);
text(7);
text(8);
}
t(0, b1('', cm ? v : NC, '|'));
t(1, b2('', v, '_', cm ? v : NC, '|'));
t(2, b3('', v, '_', v, '_', cm ? v : NC, '|'));
t(3, b4('', v, '_', v, '_', v, '_', cm ? v : NC, '|'));
t(4, b5('', v, '_', v, '_', v, '_', v, '_', cm ? v : NC, '|'));
t(5, b6('', v, '_', v, '_', v, '_', v, '_', v, '_', cm ? v : NC, '|'));
t(6, b7('', v, '_', v, '_', v, '_', v, '_', v, '_', v, '_', cm ? v : NC, '|'));
t(7, b8('', v, '_', v, '_', v, '_', v, '_', v, '_', v, '_', v, '_', cm ? v : NC, '|'));
t(8, bV([
'', v, '_', v, '_', v, '_', v, '_', v, '_', v, '_', v, '_', v, '_', cm ? v : NC, ''
]));
textBinding(0, bind1('', cm ? v : NO_CHANGE, '|'));
textBinding(1, bind2('', v, '_', cm ? v : NO_CHANGE, '|'));
textBinding(2, bind3('', v, '_', v, '_', cm ? v : NO_CHANGE, '|'));
textBinding(3, bind4('', v, '_', v, '_', v, '_', cm ? v : NO_CHANGE, '|'));
textBinding(4, bind5('', v, '_', v, '_', v, '_', v, '_', cm ? v : NO_CHANGE, '|'));
textBinding(5, bind6('', v, '_', v, '_', v, '_', v, '_', v, '_', cm ? v : NO_CHANGE, '|'));
textBinding(
6, bind7('', v, '_', v, '_', v, '_', v, '_', v, '_', v, '_', cm ? v : NO_CHANGE, '|'));
textBinding(
7, bind8(
'', v, '_', v, '_', v, '_', v, '_', v, '_', v, '_', v, '_', cm ? v : NO_CHANGE,
'|'));
textBinding(8, bindV([
'', v, '_', v, '_', v, '_', v, '_', v, '_', v, '_', v, '_', v, '_',
cm ? v : NO_CHANGE, ''
]));
}
expect(renderToHtml(Template, 'a'))
.toEqual(
@ -117,11 +122,11 @@ describe('render3 integration test', () => {
it('should handle a flat list of static/bound text nodes', () => {
function Template(name: string, cm: boolean) {
if (cm) {
T(0, 'Hello ');
T(1);
T(2, '!');
text(0, 'Hello ');
text(1);
text(2, '!');
}
t(1, b(name));
textBinding(1, bind(name));
}
expect(renderToHtml(Template, 'world')).toEqual('Hello world!');
expect(renderToHtml(Template, 'monde')).toEqual('Hello monde!');
@ -130,15 +135,15 @@ describe('render3 integration test', () => {
it('should handle a list of static/bound text nodes as element children', () => {
function Template(name: string, cm: boolean) {
if (cm) {
E(0, 'b');
elementStart(0, 'b');
{
T(1, 'Hello ');
T(2);
T(3, '!');
text(1, 'Hello ');
text(2);
text(3, '!');
}
e();
elementEnd();
}
t(2, b(name));
textBinding(2, bind(name));
}
expect(renderToHtml(Template, 'world')).toEqual('<b>Hello world!</b>');
expect(renderToHtml(Template, 'mundo')).toEqual('<b>Hello mundo!</b>');
@ -147,23 +152,23 @@ describe('render3 integration test', () => {
it('should render/update text node as a child of a deep list of elements', () => {
function Template(name: string, cm: boolean) {
if (cm) {
E(0, 'b');
elementStart(0, 'b');
{
E(1, 'b');
elementStart(1, 'b');
{
E(2, 'b');
elementStart(2, 'b');
{
E(3, 'b');
{ T(4); }
e();
elementStart(3, 'b');
{ text(4); }
elementEnd();
}
e();
elementEnd();
}
e();
elementEnd();
}
e();
elementEnd();
}
t(4, b1('Hello ', name, '!'));
textBinding(4, bind1('Hello ', name, '!'));
}
expect(renderToHtml(Template, 'world')).toEqual('<b><b><b><b>Hello world!</b></b></b></b>');
expect(renderToHtml(Template, 'mundo')).toEqual('<b><b><b><b>Hello mundo!</b></b></b></b>');
@ -172,17 +177,17 @@ describe('render3 integration test', () => {
it('should update 2 sibling elements', () => {
function Template(id: any, cm: boolean) {
if (cm) {
E(0, 'b');
elementStart(0, 'b');
{
E(1, 'span');
e();
E(2, 'span', ['class', 'foo']);
elementStart(1, 'span');
elementEnd();
elementStart(2, 'span', ['class', 'foo']);
{}
e();
elementEnd();
}
e();
elementEnd();
}
a(2, 'id', b(id));
elementAttribute(2, 'id', bind(id));
}
expect(renderToHtml(Template, 'foo'))
.toEqual('<b><span></span><span class="foo" id="foo"></span></b>');
@ -193,10 +198,10 @@ describe('render3 integration test', () => {
it('should handle sibling text node after element with child text node', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'p');
{ T(1, 'hello'); }
e();
T(2, 'world');
elementStart(0, 'p');
{ text(1, 'hello'); }
elementEnd();
text(2, 'world');
}
}
@ -214,14 +219,14 @@ describe('render3 integration test', () => {
tag: 'todo',
template: function TodoTemplate(ctx: any, cm: boolean) {
if (cm) {
E(0, 'p');
elementStart(0, 'p');
{
T(1, 'Todo');
T(2);
text(1, 'Todo');
text(2);
}
e();
elementEnd();
}
t(2, b(ctx.value));
textBinding(2, bind(ctx.value));
},
factory: () => new TodoComponent
});
@ -230,11 +235,11 @@ describe('render3 integration test', () => {
it('should support a basic component template', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, TodoComponent);
e();
elementStart(0, TodoComponent);
elementEnd();
}
TodoComponent.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
expect(renderToHtml(Template, null)).toEqual('<todo><p>Todo one</p></todo>');
@ -243,12 +248,12 @@ describe('render3 integration test', () => {
it('should support a component template with sibling', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, TodoComponent);
e();
T(2, 'two');
elementStart(0, TodoComponent);
elementEnd();
text(2, 'two');
}
TodoComponent.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
expect(renderToHtml(Template, null)).toEqual('<todo><p>Todo one</p></todo>two');
});
@ -260,15 +265,15 @@ describe('render3 integration test', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, TodoComponent);
e();
E(2, TodoComponent);
e();
elementStart(0, TodoComponent);
elementEnd();
elementStart(2, TodoComponent);
elementEnd();
}
TodoComponent.ngComponentDef.h(1, 0);
TodoComponent.ngComponentDef.h(3, 2);
r(1, 0);
r(3, 2);
componentRefresh(1, 0);
componentRefresh(3, 2);
}
expect(renderToHtml(Template, null))
.toEqual('<todo><p>Todo one</p></todo><todo><p>Todo one</p></todo>');
@ -285,25 +290,27 @@ describe('render3 integration test', () => {
template: function TodoComponentHostBindingTemplate(
ctx: TodoComponentHostBinding, cm: boolean) {
if (cm) {
T(0);
text(0);
}
t(0, b(ctx.title));
textBinding(0, bind(ctx.title));
},
factory: () => cmptInstance = new TodoComponentHostBinding,
hostBindings: function(directiveIndex: number, elementIndex: number): void {
// host bindings
p(elementIndex, 'title', b(m<TodoComponentHostBinding>(directiveIndex).title));
elementProperty(
elementIndex, 'title',
bind(memory<TodoComponentHostBinding>(directiveIndex).title));
}
});
}
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, TodoComponentHostBinding);
e();
elementStart(0, TodoComponentHostBinding);
elementEnd();
}
TodoComponentHostBinding.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
expect(renderToHtml(Template, {})).toEqual('<todo title="one">one</todo>');
@ -320,11 +327,11 @@ describe('render3 integration test', () => {
tag: 'comp',
template: function MyCompTemplate(ctx: any, cm: boolean) {
if (cm) {
E(0, 'p');
{ T(1); }
e();
elementStart(0, 'p');
{ text(1); }
elementEnd();
}
t(1, b(ctx.name));
textBinding(1, bind(ctx.name));
},
factory: () => new MyComp
});
@ -332,11 +339,11 @@ describe('render3 integration test', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, MyComp);
e();
elementStart(0, MyComp);
elementEnd();
}
MyComp.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
expect(renderToHtml(Template, null)).toEqual('<comp><p>Bess</p></comp>');
@ -355,20 +362,20 @@ describe('render3 integration test', () => {
tag: 'comp',
template: function MyCompTemplate(ctx: any, cm: boolean) {
if (cm) {
C(0);
container(0);
}
cR(0);
containerRefreshStart(0);
{
if (ctx.condition) {
if (V(0)) {
E(0, 'div');
{ T(1, 'text'); }
e();
if (viewStart(0)) {
elementStart(0, 'div');
{ text(1, 'text'); }
elementEnd();
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
},
factory: () => new MyComp,
inputs: {condition: 'condition'}
@ -378,12 +385,12 @@ describe('render3 integration test', () => {
/** <comp [condition]="condition"></comp> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, MyComp);
e();
elementStart(0, MyComp);
elementEnd();
}
p(0, 'condition', b(ctx.condition));
elementProperty(0, 'condition', bind(ctx.condition));
MyComp.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
expect(renderToHtml(Template, {condition: true})).toEqual('<comp><div>text</div></comp>');
@ -408,50 +415,50 @@ describe('render3 integration test', () => {
function showLabel(ctx: {label: string | undefined}, cm: boolean) {
if (cm) {
C(0);
container(0);
}
cR(0);
containerRefreshStart(0);
{
if (ctx.label != null) {
if (V(0)) {
T(0);
if (viewStart(0)) {
text(0);
}
t(0, b(ctx.label));
v();
textBinding(0, bind(ctx.label));
viewEnd();
}
}
cr();
containerRefreshEnd();
}
function showTree(ctx: {tree: Tree}, cm: boolean) {
if (cm) {
C(0);
C(1);
C(2);
container(0);
container(1);
container(2);
}
cR(0);
containerRefreshStart(0);
{
const cm0 = V(0);
const cm0 = viewStart(0);
{ showLabel({label: ctx.tree.beforeLabel}, cm0); }
v();
viewEnd();
}
cr();
cR(1);
containerRefreshEnd();
containerRefreshStart(1);
{
for (let subTree of ctx.tree.subTrees || []) {
const cm0 = V(0);
const cm0 = viewStart(0);
{ showTree({tree: subTree}, cm0); }
v();
viewEnd();
}
}
cr();
cR(2);
containerRefreshEnd();
containerRefreshStart(2);
{
const cm0 = V(0);
const cm0 = viewStart(0);
{ showLabel({label: ctx.tree.afterLabel}, cm0); }
v();
viewEnd();
}
cr();
containerRefreshEnd();
}
class ChildComponent {
@ -463,25 +470,25 @@ describe('render3 integration test', () => {
template: function ChildComponentTemplate(
ctx: {beforeTree: Tree, afterTree: Tree}, cm: boolean) {
if (cm) {
pD(0);
C(1);
P(2, 0);
C(3);
projectionDef(0);
container(1);
projection(2, 0);
container(3);
}
cR(1);
containerRefreshStart(1);
{
const cm0 = V(0);
const cm0 = viewStart(0);
{ showTree({tree: ctx.beforeTree}, cm0); }
v();
viewEnd();
}
cr();
cR(3);
containerRefreshEnd();
containerRefreshStart(3);
{
const cm0 = V(0);
const cm0 = viewStart(0);
{ showTree({tree: ctx.afterTree}, cm0); }
v();
viewEnd();
}
cr();
containerRefreshEnd();
},
factory: () => new ChildComponent,
inputs: {beforeTree: 'beforeTree', afterTree: 'afterTree'}
@ -490,21 +497,21 @@ describe('render3 integration test', () => {
function parentTemplate(ctx: ParentCtx, cm: boolean) {
if (cm) {
E(0, ChildComponent);
{ C(2); }
e();
elementStart(0, ChildComponent);
{ container(2); }
elementEnd();
}
p(0, 'beforeTree', b(ctx.beforeTree));
p(0, 'afterTree', b(ctx.afterTree));
cR(2);
elementProperty(0, 'beforeTree', bind(ctx.beforeTree));
elementProperty(0, 'afterTree', bind(ctx.afterTree));
containerRefreshStart(2);
{
const cm0 = V(0);
const cm0 = viewStart(0);
{ showTree({tree: ctx.projectedTree}, cm0); }
v();
viewEnd();
}
cr();
containerRefreshEnd();
ChildComponent.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
it('should work with a tree', () => {
@ -537,10 +544,10 @@ describe('render3 integration test', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'span');
e();
elementStart(0, 'span');
elementEnd();
}
a(0, 'title', b(ctx.title));
elementAttribute(0, 'title', bind(ctx.title));
}
// initial binding
@ -560,10 +567,10 @@ describe('render3 integration test', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'span');
e();
elementStart(0, 'span');
elementEnd();
}
a(0, 'title', b(ctx.title));
elementAttribute(0, 'title', bind(ctx.title));
}
expect(renderToHtml(Template, ctx)).toEqual('<span title="NaN"></span>');
@ -575,22 +582,29 @@ describe('render3 integration test', () => {
it('should update bindings', () => {
function Template(c: any, cm: boolean) {
if (cm) {
E(0, 'b');
e();
elementStart(0, 'b');
elementEnd();
}
a(0, 'a', bV(c));
a(0, 'a0', b(c[1]));
a(0, 'a1', b1(c[0], c[1], c[16]));
a(0, 'a2', b2(c[0], c[1], c[2], c[3], c[16]));
a(0, 'a3', b3(c[0], c[1], c[2], c[3], c[4], c[5], c[16]));
a(0, 'a4', b4(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[16]));
a(0, 'a5', b5(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[16]));
a(0, 'a6',
b6(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[10], c[11], c[16]));
a(0, 'a7', b7(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[10], c[11],
c[12], c[13], c[16]));
a(0, 'a8', b8(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[10], c[11],
c[12], c[13], c[14], c[15], c[16]));
elementAttribute(0, 'a', bindV(c));
elementAttribute(0, 'a0', bind(c[1]));
elementAttribute(0, 'a1', bind1(c[0], c[1], c[16]));
elementAttribute(0, 'a2', bind2(c[0], c[1], c[2], c[3], c[16]));
elementAttribute(0, 'a3', bind3(c[0], c[1], c[2], c[3], c[4], c[5], c[16]));
elementAttribute(0, 'a4', bind4(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[16]));
elementAttribute(
0, 'a5', bind5(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[16]));
elementAttribute(
0, 'a6',
bind6(
c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[10], c[11], c[16]));
elementAttribute(
0, 'a7', bind7(
c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[10], c[11],
c[12], c[13], c[16]));
elementAttribute(
0, 'a8', bind8(
c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[10], c[11],
c[12], c[13], c[14], c[15], c[16]));
}
let args = ['(', 0, 'a', 1, 'b', 2, 'c', 3, 'd', 4, 'e', 5, 'f', 6, 'g', 7, ')'];
expect(renderToHtml(Template, args))
@ -611,27 +625,27 @@ describe('render3 integration test', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'span');
C(1);
e();
elementStart(0, 'span');
container(1);
elementEnd();
}
a(0, 'title', b(ctx.title));
cR(1);
elementAttribute(0, 'title', bind(ctx.title));
containerRefreshStart(1);
{
if (true) {
let cm1 = V(1);
let cm1 = viewStart(1);
{
if (cm1) {
E(0, 'b');
elementStart(0, 'b');
{}
e();
elementEnd();
}
a(0, 'title', b(ctx.title));
elementAttribute(0, 'title', bind(ctx.title));
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
// initial binding
@ -653,10 +667,10 @@ describe('render3 integration test', () => {
it('should support binding to styles', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'span');
e();
elementStart(0, 'span');
elementEnd();
}
s(0, 'border-color', b(ctx));
elementStyle(0, 'border-color', bind(ctx));
}
expect(renderToHtml(Template, 'red')).toEqual('<span style="border-color: red;"></span>');
@ -668,10 +682,10 @@ describe('render3 integration test', () => {
it('should support binding to styles with suffix', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'span');
e();
elementStart(0, 'span');
elementEnd();
}
s(0, 'font-size', b(ctx), 'px');
elementStyle(0, 'font-size', bind(ctx), 'px');
}
expect(renderToHtml(Template, '100')).toEqual('<span style="font-size: 100px;"></span>');
@ -685,10 +699,10 @@ describe('render3 integration test', () => {
it('should support CSS class toggle', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'span');
e();
elementStart(0, 'span');
elementEnd();
}
k(0, 'active', b(ctx));
elementClass(0, 'active', bind(ctx));
}
expect(renderToHtml(Template, true)).toEqual('<span class="active"></span>');
@ -706,10 +720,10 @@ describe('render3 integration test', () => {
it('should work correctly with existing static classes', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'span', ['class', 'existing']);
e();
elementStart(0, 'span', ['class', 'existing']);
elementEnd();
}
k(0, 'active', b(ctx));
elementClass(0, 'active', bind(ctx));
}
expect(renderToHtml(Template, true)).toEqual('<span class="existing active"></span>');
@ -728,20 +742,20 @@ describe('render3 integration test', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
C(0);
container(0);
}
cR(0);
containerRefreshStart(0);
{
if (ctx.condition) {
if (V(0)) {
E(0, 'div');
if (viewStart(0)) {
elementStart(0, 'div');
{}
e();
elementEnd();
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
expect((Template as any).ngPrivateData).toBeUndefined();

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {C, E, L, T, V, cR, cr, defineComponent, e, r, v} from '../../src/render3/index';
import {defineComponent} from '../../src/render3/index';
import {componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementStart, listener, text, viewEnd, viewStart} from '../../src/render3/instructions';
import {containerEl, renderComponent, renderToHtml} from './render_util';
@ -26,12 +27,12 @@ describe('event listeners', () => {
/** <button (click)="onClick()"> Click me </button> */
template: function CompTemplate(ctx: any, cm: boolean) {
if (cm) {
E(0, 'button');
elementStart(0, 'button');
{
L('click', ctx.onClick.bind(ctx));
T(1, 'Click me');
listener('click', ctx.onClick.bind(ctx));
text(1, 'Click me');
}
e();
elementEnd();
}
},
factory: () => {
@ -59,12 +60,12 @@ describe('event listeners', () => {
/** <button (click)="showing=!showing"> Click me </button> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'button');
elementStart(0, 'button');
{
L('click', () => ctx.showing = !ctx.showing);
T(1, 'Click me');
listener('click', () => ctx.showing = !ctx.showing);
text(1, 'Click me');
}
e();
elementEnd();
}
}
@ -88,23 +89,23 @@ describe('event listeners', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
C(0);
container(0);
}
cR(0);
containerRefreshStart(0);
{
if (ctx.showing) {
if (V(1)) {
E(0, 'button');
if (viewStart(1)) {
elementStart(0, 'button');
{
L('click', ctx.onClick.bind(ctx));
T(1, 'Click me');
listener('click', ctx.onClick.bind(ctx));
text(1, 'Click me');
}
e();
elementEnd();
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
let comp = new MyComp();
@ -136,34 +137,34 @@ describe('event listeners', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
C(0);
container(0);
}
cR(0);
containerRefreshStart(0);
{
if (ctx.showing) {
if (V(0)) {
T(0, 'Hello');
C(1);
if (viewStart(0)) {
text(0, 'Hello');
container(1);
}
cR(1);
containerRefreshStart(1);
{
if (ctx.button) {
if (V(0)) {
E(0, 'button');
if (viewStart(0)) {
elementStart(0, 'button');
{
L('click', ctx.onClick.bind(ctx));
T(1, 'Click');
listener('click', ctx.onClick.bind(ctx));
text(1, 'Click');
}
e();
elementEnd();
}
v();
viewEnd();
}
}
cr();
v();
containerRefreshEnd();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
const comp = {showing: true, counter: 0, button: true, onClick: function() { this.counter++; }};
@ -194,26 +195,26 @@ describe('event listeners', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
C(0);
container(0);
}
cR(0);
containerRefreshStart(0);
{
if (ctx.showing) {
if (V(0)) {
T(0, 'Hello');
E(1, MyComp);
e();
E(3, MyComp);
e();
if (viewStart(0)) {
text(0, 'Hello');
elementStart(1, MyComp);
elementEnd();
elementStart(3, MyComp);
elementEnd();
}
MyComp.ngComponentDef.h(2, 1);
MyComp.ngComponentDef.h(4, 3);
r(2, 1);
r(4, 3);
v();
componentRefresh(2, 1);
componentRefresh(4, 3);
viewEnd();
}
}
cr();
containerRefreshEnd();
}
const ctx = {showing: true};
@ -250,50 +251,50 @@ describe('event listeners', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
C(0);
container(0);
}
cR(0);
containerRefreshStart(0);
{
if (ctx.condition) {
if (V(0)) {
T(0, 'Hello');
C(1);
C(2);
if (viewStart(0)) {
text(0, 'Hello');
container(1);
container(2);
}
cR(1);
containerRefreshStart(1);
{
if (ctx.sub1) {
if (V(0)) {
E(0, 'button');
if (viewStart(0)) {
elementStart(0, 'button');
{
L('click', () => ctx.counter1++);
T(1, 'Click');
listener('click', () => ctx.counter1++);
text(1, 'Click');
}
e();
elementEnd();
}
v();
viewEnd();
}
}
cr();
cR(2);
containerRefreshEnd();
containerRefreshStart(2);
{
if (ctx.sub2) {
if (V(0)) {
E(0, 'button');
if (viewStart(0)) {
elementStart(0, 'button');
{
L('click', () => ctx.counter2++);
T(1, 'Click');
listener('click', () => ctx.counter2++);
text(1, 'Click');
}
e();
elementEnd();
}
v();
viewEnd();
}
}
cr();
v();
containerRefreshEnd();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
const ctx = {condition: true, counter1: 0, counter2: 0, sub1: true, sub2: true};

View File

@ -5,7 +5,9 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {E, defineComponent, e, m, o1, o2, o3, o4, o5, o6, o7, o8, p, r} from '../../src/render3/index';
import {defineComponent} from '../../src/render3/index';
import {componentRefresh, elementEnd, elementProperty, elementStart, memory} from '../../src/render3/instructions';
import {objectLiteral1, objectLiteral2, objectLiteral3, objectLiteral4, objectLiteral5, objectLiteral6, objectLiteral7, objectLiteral8} from '../../src/render3/object_literal';
import {renderToHtml} from '../../test/render3/render_util';
describe('array literals', () => {
@ -27,12 +29,12 @@ describe('array literals', () => {
/** <my-comp [names]="['Nancy', customName, 'Bess']"></my-comp> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, MyComp);
e();
elementStart(0, MyComp);
elementEnd();
}
p(0, 'names', o1(0, e0_literal, 1, ctx.customName));
elementProperty(0, 'names', objectLiteral1(0, e0_literal, 1, ctx.customName));
MyComp.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
const e0_literal = ['Nancy', null, 'Bess'];
@ -74,13 +76,13 @@ describe('array literals', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, ManyPropComp);
e();
elementStart(0, ManyPropComp);
elementEnd();
}
p(0, 'names1', o1(0, e0_literal, 1, ctx.customName));
p(0, 'names2', o1(1, e0_literal_1, 0, ctx.customName2));
elementProperty(0, 'names1', objectLiteral1(0, e0_literal, 1, ctx.customName));
elementProperty(0, 'names2', objectLiteral1(1, e0_literal_1, 0, ctx.customName2));
ManyPropComp.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
const e0_literal = ['Nancy', null];
@ -104,12 +106,13 @@ describe('array literals', () => {
/** <my-comp [names]="['Nancy', customName, 'Bess', customName2]"></my-comp> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, MyComp);
e();
elementStart(0, MyComp);
elementEnd();
}
p(0, 'names', o2(0, e0_literal, 1, ctx.customName, 3, ctx.customName2));
elementProperty(
0, 'names', objectLiteral2(0, e0_literal, 1, ctx.customName, 3, ctx.customName2));
MyComp.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
const e0_literal = ['Nancy', null, 'Bess', null];
@ -140,45 +143,53 @@ describe('array literals', () => {
function Template(c: any, cm: boolean) {
if (cm) {
E(0, MyComp);
o3Comp = m(1);
e();
E(2, MyComp);
o4Comp = m(3);
e();
E(4, MyComp);
o5Comp = m(5);
e();
E(6, MyComp);
o6Comp = m(7);
e();
E(8, MyComp);
o7Comp = m(9);
e();
E(10, MyComp);
o8Comp = m(11);
e();
elementStart(0, MyComp);
o3Comp = memory(1);
elementEnd();
elementStart(2, MyComp);
o4Comp = memory(3);
elementEnd();
elementStart(4, MyComp);
o5Comp = memory(5);
elementEnd();
elementStart(6, MyComp);
o6Comp = memory(7);
elementEnd();
elementStart(8, MyComp);
o7Comp = memory(9);
elementEnd();
elementStart(10, MyComp);
o8Comp = memory(11);
elementEnd();
}
p(0, 'names', o3(0, e0_literal, 5, c[5], 6, c[6], 7, c[7]));
p(2, 'names', o4(1, e2_literal, 4, c[4], 5, c[5], 6, c[6], 7, c[7]));
p(4, 'names', o5(2, e4_literal, 3, c[3], 4, c[4], 5, c[5], 6, c[6], 7, c[7]));
p(6, 'names', o6(3, e6_literal, 2, c[2], 3, c[3], 4, c[4], 5, c[5], 6, c[6], 7, c[7]));
p(8, 'names',
o7(4, e8_literal, 1, c[1], 2, c[2], 3, c[3], 4, c[4], 5, c[5], 6, c[6], 7, c[7]));
p(10, 'names',
o8(5, e10_literal, 0, c[0], 1, c[1], 2, c[2], 3, c[3], 4, c[4], 5, c[5], 6, c[6], 7, c[7]));
elementProperty(0, 'names', objectLiteral3(0, e0_literal, 5, c[5], 6, c[6], 7, c[7]));
elementProperty(
2, 'names', objectLiteral4(1, e2_literal, 4, c[4], 5, c[5], 6, c[6], 7, c[7]));
elementProperty(
4, 'names', objectLiteral5(2, e4_literal, 3, c[3], 4, c[4], 5, c[5], 6, c[6], 7, c[7]));
elementProperty(
6, 'names',
objectLiteral6(3, e6_literal, 2, c[2], 3, c[3], 4, c[4], 5, c[5], 6, c[6], 7, c[7]));
elementProperty(
8, 'names',
objectLiteral7(
4, e8_literal, 1, c[1], 2, c[2], 3, c[3], 4, c[4], 5, c[5], 6, c[6], 7, c[7]));
elementProperty(
10, 'names', objectLiteral8(
5, e10_literal, 0, c[0], 1, c[1], 2, c[2], 3, c[3], 4, c[4], 5, c[5], 6,
c[6], 7, c[7]));
MyComp.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
MyComp.ngComponentDef.h(3, 2);
r(3, 2);
componentRefresh(3, 2);
MyComp.ngComponentDef.h(5, 4);
r(5, 4);
componentRefresh(5, 4);
MyComp.ngComponentDef.h(7, 6);
r(7, 6);
componentRefresh(7, 6);
MyComp.ngComponentDef.h(9, 8);
r(9, 8);
componentRefresh(9, 8);
MyComp.ngComponentDef.h(11, 10);
r(11, 10);
componentRefresh(11, 10);
}
const e0_literal = ['a', 'b', 'c', 'd', 'e', null, null, null];
@ -223,12 +234,12 @@ describe('array literals', () => {
/** <object-comp [config]="{duration: 500, animation: ctx.name}"></object-comp> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, ObjectComp);
e();
elementStart(0, ObjectComp);
elementEnd();
}
p(0, 'config', o1(0, e0_literal, 'animation', ctx.name));
elementProperty(0, 'config', objectLiteral1(0, e0_literal, 'animation', ctx.name));
ObjectComp.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
const e0_literal = {duration: 500, animation: null};

View File

@ -8,7 +8,8 @@
import {EventEmitter} from '@angular/core';
import {C, E, L, T, V, b, cR, cr, defineComponent, defineDirective, e, p, r, v} from '../../src/render3/index';
import {defineComponent, defineDirective} from '../../src/render3/index';
import {bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementProperty, elementStart, listener, text, viewEnd, viewStart} from '../../src/render3/instructions';
import {containerEl, renderToHtml} from './render_util';
@ -44,12 +45,12 @@ describe('outputs', () => {
/** <button-toggle (change)="onChange()"></button-toggle> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, ButtonToggle);
{ L('change', ctx.onChange.bind(ctx)); }
e();
elementStart(0, ButtonToggle);
{ listener('change', ctx.onChange.bind(ctx)); }
elementEnd();
}
ButtonToggle.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
let counter = 0;
@ -67,15 +68,15 @@ describe('outputs', () => {
/** <button-toggle (change)="onChange()" (reset)="onReset()"></button-toggle> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, ButtonToggle);
elementStart(0, ButtonToggle);
{
L('change', ctx.onChange.bind(ctx));
L('reset', ctx.onReset.bind(ctx));
listener('change', ctx.onChange.bind(ctx));
listener('reset', ctx.onReset.bind(ctx));
}
e();
elementEnd();
}
ButtonToggle.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
let counter = 0;
@ -94,12 +95,12 @@ describe('outputs', () => {
/** <button-toggle (change)="counter++"></button-toggle> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, ButtonToggle);
{ L('change', () => ctx.counter++); }
e();
elementStart(0, ButtonToggle);
{ listener('change', () => ctx.counter++); }
elementEnd();
}
ButtonToggle.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
const ctx = {counter: 0};
@ -122,22 +123,22 @@ describe('outputs', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
C(0);
container(0);
}
cR(0);
containerRefreshStart(0);
{
if (ctx.condition) {
if (V(0)) {
E(0, ButtonToggle);
{ L('change', ctx.onChange.bind(ctx)); }
e();
if (viewStart(0)) {
elementStart(0, ButtonToggle);
{ listener('change', ctx.onChange.bind(ctx)); }
elementEnd();
}
ButtonToggle.ngComponentDef.h(1, 0);
r(1, 0);
v();
componentRefresh(1, 0);
viewEnd();
}
}
cr();
containerRefreshEnd();
}
let counter = 0;
@ -166,32 +167,32 @@ describe('outputs', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
C(0);
container(0);
}
cR(0);
containerRefreshStart(0);
{
if (ctx.condition) {
if (V(0)) {
C(0);
if (viewStart(0)) {
container(0);
}
cR(0);
containerRefreshStart(0);
{
if (ctx.condition2) {
if (V(0)) {
E(0, ButtonToggle);
{ L('change', ctx.onChange.bind(ctx)); }
e();
if (viewStart(0)) {
elementStart(0, ButtonToggle);
{ listener('change', ctx.onChange.bind(ctx)); }
elementEnd();
}
ButtonToggle.ngComponentDef.h(1, 0);
r(1, 0);
v();
componentRefresh(1, 0);
viewEnd();
}
}
cr();
v();
containerRefreshEnd();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
let counter = 0;
@ -232,32 +233,32 @@ describe('outputs', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
C(0);
container(0);
}
cR(0);
containerRefreshStart(0);
{
if (ctx.condition) {
if (V(0)) {
E(0, 'button');
if (viewStart(0)) {
elementStart(0, 'button');
{
L('click', ctx.onClick.bind(ctx));
T(1, 'Click me');
listener('click', ctx.onClick.bind(ctx));
text(1, 'Click me');
}
e();
E(2, ButtonToggle);
{ L('change', ctx.onChange.bind(ctx)); }
e();
E(4, DestroyComp);
e();
elementEnd();
elementStart(2, ButtonToggle);
{ listener('change', ctx.onChange.bind(ctx)); }
elementEnd();
elementStart(4, DestroyComp);
elementEnd();
}
ButtonToggle.ngComponentDef.h(3, 2);
DestroyComp.ngComponentDef.h(5, 4);
r(3, 2);
r(5, 4);
v();
componentRefresh(3, 2);
componentRefresh(5, 4);
viewEnd();
}
}
cr();
containerRefreshEnd();
}
let clickCounter = 0;
@ -298,9 +299,9 @@ describe('outputs', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'button', null, [MyButton]);
{ L('click', ctx.onClick.bind(ctx)); }
e();
elementStart(0, 'button', null, [MyButton]);
{ listener('click', ctx.onClick.bind(ctx)); }
elementEnd();
}
}
@ -321,12 +322,12 @@ describe('outputs', () => {
/** <button-toggle (change)="onChange()" otherDir></button-toggle> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, ButtonToggle, null, [OtherDir]);
{ L('change', ctx.onChange.bind(ctx)); }
e();
elementStart(0, ButtonToggle, null, [OtherDir]);
{ listener('change', ctx.onChange.bind(ctx)); }
elementEnd();
}
ButtonToggle.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
let counter = 0;
@ -352,13 +353,13 @@ describe('outputs', () => {
/** <button-toggle (change)="onChange()" otherDir [change]="change"></button-toggle> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, ButtonToggle, null, [OtherDir]);
{ L('change', ctx.onChange.bind(ctx)); }
e();
elementStart(0, ButtonToggle, null, [OtherDir]);
{ listener('change', ctx.onChange.bind(ctx)); }
elementEnd();
}
p(0, 'change', b(ctx.change));
elementProperty(0, 'change', bind(ctx.change));
ButtonToggle.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
let counter = 0;
@ -384,35 +385,35 @@ describe('outputs', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'button');
elementStart(0, 'button');
{
L('click', ctx.onClick.bind(ctx));
T(1, 'Click me');
listener('click', ctx.onClick.bind(ctx));
text(1, 'Click me');
}
e();
C(2);
elementEnd();
container(2);
}
cR(2);
containerRefreshStart(2);
{
if (ctx.condition) {
if (V(0)) {
E(0, ButtonToggle);
{ L('change', ctx.onChange.bind(ctx)); }
e();
if (viewStart(0)) {
elementStart(0, ButtonToggle);
{ listener('change', ctx.onChange.bind(ctx)); }
elementEnd();
}
ButtonToggle.ngComponentDef.h(1, 0);
r(1, 0);
v();
componentRefresh(1, 0);
viewEnd();
} else {
if (V(1)) {
E(0, 'div', null, [OtherDir]);
{ L('change', ctx.onChange.bind(ctx)); }
e();
if (viewStart(1)) {
elementStart(0, 'div', null, [OtherDir]);
{ listener('change', ctx.onChange.bind(ctx)); }
elementEnd();
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
let counter = 0;

View File

@ -8,8 +8,8 @@
import {EventEmitter} from '@angular/core';
import {C, E, L, T, V, b, b1, cR, cr, defineComponent, defineDirective, e, m, p, r, t, v} from '../../src/render3/index';
import {NO_CHANGE} from '../../src/render3/instructions';
import {defineComponent, defineDirective} from '../../src/render3/index';
import {NO_CHANGE, bind, bind1, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementProperty, elementStart, listener, memory, text, textBinding, viewEnd, viewStart} from '../../src/render3/instructions';
import {renderToHtml} from './render_util';
@ -18,10 +18,10 @@ describe('elementProperty', () => {
it('should support bindings to properties', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'span');
e();
elementStart(0, 'span');
elementEnd();
}
p(0, 'id', b(ctx));
elementProperty(0, 'id', bind(ctx));
}
expect(renderToHtml(Template, 'testId')).toEqual('<span id="testId"></span>');
@ -39,10 +39,10 @@ describe('elementProperty', () => {
function Template(ctx: string, cm: boolean) {
if (cm) {
E(0, 'span');
e();
elementStart(0, 'span');
elementEnd();
}
p(0, 'id', cm ? expensive(ctx) : NO_CHANGE);
elementProperty(0, 'id', cm ? expensive(ctx) : NO_CHANGE);
}
expect(renderToHtml(Template, 'cheapId')).toEqual('<span id="cheapId"></span>');
@ -52,10 +52,10 @@ describe('elementProperty', () => {
it('should support interpolation for properties', () => {
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'span');
e();
elementStart(0, 'span');
elementEnd();
}
p(0, 'id', b1('_', ctx, '_'));
elementProperty(0, 'id', bind1('_', ctx, '_'));
}
expect(renderToHtml(Template, 'testId')).toEqual('<span id="_testId_"></span>');
@ -90,13 +90,13 @@ describe('elementProperty', () => {
/** <button myButton [id]="id" [disabled]="isDisabled">Click me</button> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'button', null, [MyButton, OtherDir]);
{ T(3, 'Click me'); }
e();
elementStart(0, 'button', null, [MyButton, OtherDir]);
{ text(3, 'Click me'); }
elementEnd();
}
p(0, 'disabled', b(ctx.isDisabled));
p(0, 'id', b(ctx.id));
elementProperty(0, 'disabled', bind(ctx.isDisabled));
elementProperty(0, 'id', bind(ctx.id));
}
const ctx: any = {isDisabled: true, id: 0};
@ -116,13 +116,13 @@ describe('elementProperty', () => {
/** <button myButton [id]="id" [disabled]="isDisabled">Click me</button> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'button', null, [MyButton]);
{ T(2, 'Click me'); }
e();
elementStart(0, 'button', null, [MyButton]);
{ text(2, 'Click me'); }
elementEnd();
}
p(0, 'disabled', b(ctx.isDisabled));
p(0, 'id', b(ctx.id));
elementProperty(0, 'disabled', bind(ctx.isDisabled));
elementProperty(0, 'id', bind(ctx.id));
}
const ctx: any = {isDisabled: true, id: 0};
@ -152,12 +152,12 @@ describe('elementProperty', () => {
/** <comp [id]="id"></comp> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, Comp);
e();
elementStart(0, Comp);
elementEnd();
}
p(0, 'id', b(ctx.id));
elementProperty(0, 'id', bind(ctx.id));
Comp.ngComponentDef.h(1, 0);
r(1, 0);
componentRefresh(1, 0);
}
expect(renderToHtml(Template, {id: 1})).toEqual(`<comp></comp>`);
@ -183,11 +183,11 @@ describe('elementProperty', () => {
/** <button myButton otherDisabledDir [disabled]="isDisabled">Click me</button> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'button', null, [MyButton, OtherDisabledDir]);
{ T(3, 'Click me'); }
e();
elementStart(0, 'button', null, [MyButton, OtherDisabledDir]);
{ text(3, 'Click me'); }
elementEnd();
}
p(0, 'disabled', b(ctx.isDisabled));
elementProperty(0, 'disabled', bind(ctx.isDisabled));
}
const ctx: any = {isDisabled: true};
@ -205,14 +205,14 @@ describe('elementProperty', () => {
/** <button otherDir [id]="id" (click)="onClick()">Click me</button> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'button', null, [OtherDir]);
elementStart(0, 'button', null, [OtherDir]);
{
L('click', ctx.onClick.bind(ctx));
T(2, 'Click me');
listener('click', ctx.onClick.bind(ctx));
text(2, 'Click me');
}
e();
elementEnd();
}
p(0, 'id', b(ctx.id));
elementProperty(0, 'id', bind(ctx.id));
}
let counter = 0;
@ -248,33 +248,33 @@ describe('elementProperty', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'button', null, [IdDir]);
{ T(2, 'Click me'); }
e();
C(3);
elementStart(0, 'button', null, [IdDir]);
{ text(2, 'Click me'); }
elementEnd();
container(3);
}
p(0, 'id', b(ctx.id1));
cR(3);
elementProperty(0, 'id', bind(ctx.id1));
containerRefreshStart(3);
{
if (ctx.condition) {
if (V(0)) {
E(0, 'button');
{ T(1, 'Click me too'); }
e();
if (viewStart(0)) {
elementStart(0, 'button');
{ text(1, 'Click me too'); }
elementEnd();
}
p(0, 'id', b(ctx.id2));
v();
elementProperty(0, 'id', bind(ctx.id2));
viewEnd();
} else {
if (V(1)) {
E(0, 'button', null, [OtherDir]);
{ T(2, 'Click me too'); }
e();
if (viewStart(1)) {
elementStart(0, 'button', null, [OtherDir]);
{ text(2, 'Click me too'); }
elementEnd();
}
p(0, 'id', b(ctx.id3));
v();
elementProperty(0, 'id', bind(ctx.id3));
viewEnd();
}
}
cr();
containerRefreshEnd();
}
expect(renderToHtml(Template, {condition: true, id1: 'one', id2: 'two', id3: 'three'}))
@ -317,8 +317,8 @@ describe('elementProperty', () => {
/** <div role="button" myDir></div> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div', ['role', 'button'], [MyDir]);
e();
elementStart(0, 'div', ['role', 'button'], [MyDir]);
elementEnd();
}
}
@ -331,10 +331,10 @@ describe('elementProperty', () => {
/** <div role="button" [role]="role" myDir></div> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div', ['role', 'button'], [MyDir]);
e();
elementStart(0, 'div', ['role', 'button'], [MyDir]);
elementEnd();
}
p(0, 'role', b(ctx.role));
elementProperty(0, 'role', bind(ctx.role));
}
expect(renderToHtml(Template, {role: 'listbox'})).toEqual(`<div role="button"></div>`);
@ -349,8 +349,8 @@ describe('elementProperty', () => {
/** <div role="button" myDir myDirB></div> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div', ['role', 'button'], [MyDir, MyDirB]);
e();
elementStart(0, 'div', ['role', 'button'], [MyDir, MyDirB]);
elementEnd();
}
}
@ -364,8 +364,8 @@ describe('elementProperty', () => {
/** <div role="button" dir="rtl" myDir></div> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div', ['role', 'button', 'dir', 'rtl'], [MyDir]);
e();
elementStart(0, 'div', ['role', 'button', 'dir', 'rtl'], [MyDir]);
elementEnd();
}
}
@ -379,9 +379,9 @@ describe('elementProperty', () => {
/** <div role="button" (change)="onChange()" myDir></div> */
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div', ['role', 'button'], [MyDir]);
{ L('change', ctx.onChange.bind(ctx)); }
e();
elementStart(0, 'div', ['role', 'button'], [MyDir]);
{ listener('change', ctx.onChange.bind(ctx)); }
elementEnd();
}
}
@ -404,10 +404,10 @@ describe('elementProperty', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div', ['role', 'button', 'dir', 'rtl'], [MyDir]);
e();
E(2, 'div', ['role', 'listbox'], [MyDirB]);
e();
elementStart(0, 'div', ['role', 'button', 'dir', 'rtl'], [MyDir]);
elementEnd();
elementStart(2, 'div', ['role', 'listbox'], [MyDirB]);
elementEnd();
}
}
@ -430,28 +430,28 @@ describe('elementProperty', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div', ['role', 'listbox'], [MyDir]);
e();
C(2);
elementStart(0, 'div', ['role', 'listbox'], [MyDir]);
elementEnd();
container(2);
}
cR(2);
containerRefreshStart(2);
{
if (ctx.condition) {
if (V(0)) {
E(0, 'div', ['role', 'button'], [MyDirB]);
e();
if (viewStart(0)) {
elementStart(0, 'div', ['role', 'button'], [MyDirB]);
elementEnd();
}
v();
viewEnd();
} else {
if (V(1)) {
E(0, 'div', ['role', 'menu']);
if (viewStart(1)) {
elementStart(0, 'div', ['role', 'menu']);
{}
e();
elementEnd();
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
expect(renderToHtml(Template, {
@ -475,11 +475,11 @@ describe('elementProperty', () => {
tag: 'comp',
template: function(ctx: any, cm: boolean) {
if (cm) {
E(0, 'div', ['role', 'button'], [MyDir]);
e();
T(2);
elementStart(0, 'div', ['role', 'button'], [MyDir]);
elementEnd();
text(2);
}
t(2, b(m<MyDir>(1).role));
textBinding(2, bind(memory<MyDir>(1).role));
},
factory: () => new Comp()
});
@ -492,21 +492,21 @@ describe('elementProperty', () => {
*/
function Template(ctx: any, cm: boolean) {
if (cm) {
C(0);
container(0);
}
cR(0);
containerRefreshStart(0);
{
for (let i = 0; i < 2; i++) {
if (V(0)) {
E(0, Comp);
e();
if (viewStart(0)) {
elementStart(0, Comp);
elementEnd();
}
Comp.ngComponentDef.h(1, 0);
r(1, 0);
v();
componentRefresh(1, 0);
viewEnd();
}
}
cr();
containerRefreshEnd();
}
expect(renderToHtml(Template, {}))

View File

@ -6,12 +6,13 @@
* 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 {C, E, Q, QueryList, V, cR, cr, detectChanges, e, m, qR, v} from '../../src/render3/index';
import {QueryList, detectChanges} from '../../src/render3/index';
import {container, containerRefreshEnd, containerRefreshStart, elementEnd, elementStart, memory, viewEnd, viewStart} from '../../src/render3/instructions';
import {query, queryRefresh} from '../../src/render3/query';
import {createComponent, createDirective, renderComponent} from './render_util';
/**
* Helper function to check if a given candidate object resembles ElementRef
* @param candidate
@ -58,19 +59,19 @@ describe('query', () => {
*/
let tmp: any;
if (cm) {
Q(0, Child, false);
Q(1, Child, true);
E(2, Child);
query(0, Child, false);
query(1, Child, true);
elementStart(2, Child);
{
child1 = m(3);
E(4, Child);
{ child2 = m(5); }
e();
child1 = memory(3);
elementStart(4, Child);
{ child2 = memory(5); }
elementEnd();
}
e();
elementEnd();
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query0 = tmp as QueryList<any>);
qR(tmp = m<QueryList<any>>(1)) && (ctx.query1 = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query0 = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(1)) && (ctx.query1 = tmp as QueryList<any>);
});
const parent = renderComponent(Cmp);
@ -92,18 +93,18 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, Child, false, QUERY_READ_ELEMENT_REF);
elToQuery = E(1, 'div', null, [Child]);
e();
query(0, Child, false, QUERY_READ_ELEMENT_REF);
elToQuery = elementStart(1, 'div', null, [Child]);
elementEnd();
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(1);
expect(isElementRef(query.first)).toBeTruthy();
expect(query.first.nativeElement).toEqual(elToQuery);
const qList = (cmptInstance.query as QueryList<any>);
expect(qList.length).toBe(1);
expect(isElementRef(qList.first)).toBeTruthy();
expect(qList.first.nativeElement).toEqual(elToQuery);
});
@ -120,18 +121,18 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, Child, false, OtherChild);
E(1, 'div', null, [Child, OtherChild]);
{ otherChildInstance = m(3); }
e();
query(0, Child, false, OtherChild);
elementStart(1, 'div', null, [Child, OtherChild]);
{ otherChildInstance = memory(3); }
elementEnd();
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(1);
expect(query.first).toBe(otherChildInstance);
const qList = (cmptInstance.query as QueryList<any>);
expect(qList.length).toBe(1);
expect(qList.first).toBe(otherChildInstance);
});
it('should not add results to query if a requested token cant be read', () => {
@ -146,16 +147,16 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, Child, false, OtherChild);
E(1, 'div', null, [Child]);
e();
query(0, Child, false, OtherChild);
elementStart(1, 'div', null, [Child]);
elementEnd();
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(0);
const qList = (cmptInstance.query as QueryList<any>);
expect(qList.length).toBe(0);
});
});
@ -174,19 +175,19 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo'], false, QUERY_READ_FROM_NODE);
elToQuery = E(1, 'div', null, null, ['foo', '']);
e();
E(2, 'div');
e();
query(0, ['foo'], false, QUERY_READ_FROM_NODE);
elToQuery = elementStart(1, 'div', null, null, ['foo', '']);
elementEnd();
elementStart(2, 'div');
elementEnd();
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(1);
expect(query.first.nativeElement).toEqual(elToQuery);
const qList = (cmptInstance.query as QueryList<any>);
expect(qList.length).toBe(1);
expect(qList.first.nativeElement).toEqual(elToQuery);
});
it('should query for multiple elements and read ElementRef by default', () => {
@ -204,22 +205,22 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo', 'bar'], undefined, QUERY_READ_FROM_NODE);
el1ToQuery = E(1, 'div', null, null, ['foo', '']);
e();
E(2, 'div');
e();
el2ToQuery = E(3, 'div', null, null, ['bar', '']);
e();
query(0, ['foo', 'bar'], undefined, QUERY_READ_FROM_NODE);
el1ToQuery = elementStart(1, 'div', null, null, ['foo', '']);
elementEnd();
elementStart(2, 'div');
elementEnd();
el2ToQuery = elementStart(3, 'div', null, null, ['bar', '']);
elementEnd();
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(2);
expect(query.first.nativeElement).toEqual(el1ToQuery);
expect(query.last.nativeElement).toEqual(el2ToQuery);
const qList = (cmptInstance.query as QueryList<any>);
expect(qList.length).toBe(2);
expect(qList.first.nativeElement).toEqual(el1ToQuery);
expect(qList.last.nativeElement).toEqual(el2ToQuery);
});
it('should read ElementRef from an element when explicitly asked for', () => {
@ -235,20 +236,20 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo'], false, QUERY_READ_ELEMENT_REF);
elToQuery = E(1, 'div', null, null, ['foo', '']);
e();
E(2, 'div');
e();
query(0, ['foo'], false, QUERY_READ_ELEMENT_REF);
elToQuery = elementStart(1, 'div', null, null, ['foo', '']);
elementEnd();
elementStart(2, 'div');
elementEnd();
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(1);
expect(isElementRef(query.first)).toBeTruthy();
expect(query.first.nativeElement).toEqual(elToQuery);
const qList = (cmptInstance.query as QueryList<any>);
expect(qList.length).toBe(1);
expect(isElementRef(qList.first)).toBeTruthy();
expect(qList.first.nativeElement).toEqual(elToQuery);
});
it('should read ViewContainerRef from element nodes when explicitly asked for', () => {
@ -261,17 +262,17 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo'], false, QUERY_READ_CONTAINER_REF);
E(1, 'div', null, null, ['foo', '']);
e();
query(0, ['foo'], false, QUERY_READ_CONTAINER_REF);
elementStart(1, 'div', null, null, ['foo', '']);
elementEnd();
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(1);
expect(isViewContainerRef(query.first)).toBeTruthy();
const qList = (cmptInstance.query as QueryList<any>);
expect(qList.length).toBe(1);
expect(isViewContainerRef(qList.first)).toBeTruthy();
});
it('should read ViewContainerRef from container nodes when explicitly asked for', () => {
@ -284,16 +285,16 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo'], false, QUERY_READ_CONTAINER_REF);
C(1, undefined, undefined, undefined, undefined, ['foo', '']);
query(0, ['foo'], false, QUERY_READ_CONTAINER_REF);
container(1, undefined, undefined, undefined, undefined, ['foo', '']);
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(1);
expect(isViewContainerRef(query.first)).toBeTruthy();
const qList = (cmptInstance.query as QueryList<any>);
expect(qList.length).toBe(1);
expect(isViewContainerRef(qList.first)).toBeTruthy();
});
it('should no longer read ElementRef with a native element pointing to comment DOM node from containers',
@ -307,16 +308,16 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo'], false, QUERY_READ_ELEMENT_REF);
C(1, undefined, undefined, undefined, undefined, ['foo', '']);
query(0, ['foo'], false, QUERY_READ_ELEMENT_REF);
container(1, undefined, undefined, undefined, undefined, ['foo', '']);
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(1);
expect(query.first.nativeElement).toBe(null);
const qList = (cmptInstance.query as QueryList<any>);
expect(qList.length).toBe(1);
expect(qList.first.nativeElement).toBe(null);
});
it('should read TemplateRef from container nodes by default', () => {
@ -330,16 +331,16 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo'], undefined, QUERY_READ_FROM_NODE);
C(1, undefined, undefined, undefined, undefined, ['foo', '']);
query(0, ['foo'], undefined, QUERY_READ_FROM_NODE);
container(1, undefined, undefined, undefined, undefined, ['foo', '']);
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(1);
expect(isTemplateRef(query.first)).toBeTruthy();
const qList = (cmptInstance.query as QueryList<any>);
expect(qList.length).toBe(1);
expect(isTemplateRef(qList.first)).toBeTruthy();
});
@ -353,16 +354,16 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo'], false, QUERY_READ_TEMPLATE_REF);
C(1, undefined, undefined, undefined, undefined, ['foo', '']);
query(0, ['foo'], false, QUERY_READ_TEMPLATE_REF);
container(1, undefined, undefined, undefined, undefined, ['foo', '']);
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(1);
expect(isTemplateRef(query.first)).toBeTruthy();
const qList = (cmptInstance.query as QueryList<any>);
expect(qList.length).toBe(1);
expect(isTemplateRef(qList.first)).toBeTruthy();
});
it('should read component instance if element queried for is a component host', () => {
@ -378,18 +379,18 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo'], true, QUERY_READ_FROM_NODE);
E(1, Child, null, null, ['foo', '']);
{ childInstance = m(2); }
e();
query(0, ['foo'], true, QUERY_READ_FROM_NODE);
elementStart(1, Child, null, null, ['foo', '']);
{ childInstance = memory(2); }
elementEnd();
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(1);
expect(query.first).toBe(childInstance);
const qList = (cmptInstance.query as QueryList<any>);
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',
@ -406,18 +407,18 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo'], true, QUERY_READ_FROM_NODE);
E(1, 'div', null, [Child], ['foo', 'child']);
childInstance = m(2);
e();
query(0, ['foo'], true, QUERY_READ_FROM_NODE);
elementStart(1, 'div', null, [Child], ['foo', 'child']);
childInstance = memory(2);
elementEnd();
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(1);
expect(query.first).toBe(childInstance);
const qList = (cmptInstance.query as QueryList<any>);
expect(qList.length).toBe(1);
expect(qList.first).toBe(childInstance);
});
it('should read all matching directive instances from a given element', () => {
@ -434,22 +435,22 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo', 'bar'], true, QUERY_READ_FROM_NODE);
E(1, 'div', null, [Child1, Child2], ['foo', 'child1', 'bar', 'child2']);
query(0, ['foo', 'bar'], true, QUERY_READ_FROM_NODE);
elementStart(1, 'div', null, [Child1, Child2], ['foo', 'child1', 'bar', 'child2']);
{
child1Instance = m(2);
child2Instance = m(3);
child1Instance = memory(2);
child2Instance = memory(3);
}
e();
elementEnd();
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(2);
expect(query.first).toBe(child1Instance);
expect(query.last).toBe(child2Instance);
const qList = (cmptInstance.query as QueryList<any>);
expect(qList.length).toBe(2);
expect(qList.first).toBe(child1Instance);
expect(qList.last).toBe(child2Instance);
});
it('should match match on exported directive name and read a requested token', () => {
@ -465,17 +466,17 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo'], undefined, QUERY_READ_ELEMENT_REF);
div = E(1, 'div', null, [Child], ['foo', 'child']);
e();
query(0, ['foo'], undefined, QUERY_READ_ELEMENT_REF);
div = elementStart(1, 'div', null, [Child], ['foo', 'child']);
elementEnd();
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(1);
expect(query.first.nativeElement).toBe(div);
const qList = (cmptInstance.query as QueryList<any>);
expect(qList.length).toBe(1);
expect(qList.first.nativeElement).toBe(div);
});
it('should support reading a mix of ElementRef and directive instances', () => {
@ -491,19 +492,19 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo', 'bar'], undefined, QUERY_READ_FROM_NODE);
div = E(1, 'div', null, [Child], ['foo', '', 'bar', 'child']);
{ childInstance = m(2); }
e();
query(0, ['foo', 'bar'], undefined, QUERY_READ_FROM_NODE);
div = elementStart(1, 'div', null, [Child], ['foo', '', 'bar', 'child']);
{ childInstance = memory(2); }
elementEnd();
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(2);
expect(query.first.nativeElement).toBe(div);
expect(query.last).toBe(childInstance);
const qList = (cmptInstance.query as QueryList<any>);
expect(qList.length).toBe(2);
expect(qList.first.nativeElement).toBe(div);
expect(qList.last).toBe(childInstance);
});
it('should not add results to query if a requested token cant be read', () => {
@ -518,16 +519,16 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo'], false, Child);
E(1, 'div', null, null, ['foo', '']);
e();
query(0, ['foo'], false, Child);
elementStart(1, 'div', null, null, ['foo', '']);
elementEnd();
}
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as QueryList<any>);
expect(query.length).toBe(0);
const qList = (cmptInstance.query as QueryList<any>);
expect(qList.length).toBe(0);
});
});
@ -547,38 +548,38 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo'], true, QUERY_READ_FROM_NODE);
C(1);
query(0, ['foo'], true, QUERY_READ_FROM_NODE);
container(1);
}
cR(1);
containerRefreshStart(1);
{
if (ctx.exp) {
let cm1 = V(1);
let cm1 = viewStart(1);
{
if (cm1) {
firstEl = E(0, 'div', null, null, ['foo', '']);
e();
firstEl = elementStart(0, 'div', null, null, ['foo', '']);
elementEnd();
}
}
v();
viewEnd();
}
}
cr();
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
containerRefreshEnd();
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as any);
expect(query.length).toBe(0);
const qList = (cmptInstance.query as any);
expect(qList.length).toBe(0);
cmptInstance.exp = true;
detectChanges(cmptInstance);
expect(query.length).toBe(1);
expect(query.first.nativeElement).toBe(firstEl);
expect(qList.length).toBe(1);
expect(qList.first.nativeElement).toBe(firstEl);
cmptInstance.exp = false;
detectChanges(cmptInstance);
expect(query.length).toBe(0);
expect(qList.length).toBe(0);
});
it('should add results from embedded views in the correct order - views and elements mix',
@ -597,48 +598,48 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo'], true, QUERY_READ_FROM_NODE);
firstEl = E(1, 'b', null, null, ['foo', '']);
e();
C(2);
lastEl = E(3, 'i', null, null, ['foo', '']);
e();
query(0, ['foo'], true, QUERY_READ_FROM_NODE);
firstEl = elementStart(1, 'b', null, null, ['foo', '']);
elementEnd();
container(2);
lastEl = elementStart(3, 'i', null, null, ['foo', '']);
elementEnd();
}
cR(2);
containerRefreshStart(2);
{
if (ctx.exp) {
let cm1 = V(1);
let cm1 = viewStart(1);
{
if (cm1) {
viewEl = E(0, 'div', null, null, ['foo', '']);
e();
viewEl = elementStart(0, 'div', null, null, ['foo', '']);
elementEnd();
}
}
v();
viewEnd();
}
}
cr();
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
containerRefreshEnd();
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as any);
expect(query.length).toBe(2);
expect(query.first.nativeElement).toBe(firstEl);
expect(query.last.nativeElement).toBe(lastEl);
const qList = (cmptInstance.query as any);
expect(qList.length).toBe(2);
expect(qList.first.nativeElement).toBe(firstEl);
expect(qList.last.nativeElement).toBe(lastEl);
cmptInstance.exp = true;
detectChanges(cmptInstance);
expect(query.length).toBe(3);
expect(query.toArray()[0].nativeElement).toBe(firstEl);
expect(query.toArray()[1].nativeElement).toBe(viewEl);
expect(query.toArray()[2].nativeElement).toBe(lastEl);
expect(qList.length).toBe(3);
expect(qList.toArray()[0].nativeElement).toBe(firstEl);
expect(qList.toArray()[1].nativeElement).toBe(viewEl);
expect(qList.toArray()[2].nativeElement).toBe(lastEl);
cmptInstance.exp = false;
detectChanges(cmptInstance);
expect(query.length).toBe(2);
expect(query.first.nativeElement).toBe(firstEl);
expect(query.last.nativeElement).toBe(lastEl);
expect(qList.length).toBe(2);
expect(qList.first.nativeElement).toBe(firstEl);
expect(qList.last.nativeElement).toBe(lastEl);
});
it('should add results from embedded views in the correct order - views side by side', () => {
@ -657,50 +658,50 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo'], true, QUERY_READ_FROM_NODE);
C(1);
query(0, ['foo'], true, QUERY_READ_FROM_NODE);
container(1);
}
cR(1);
containerRefreshStart(1);
{
if (ctx.exp1) {
let cm1 = V(0);
let cm1 = viewStart(0);
{
if (cm1) {
firstEl = E(0, 'div', null, null, ['foo', '']);
e();
firstEl = elementStart(0, 'div', null, null, ['foo', '']);
elementEnd();
}
}
v();
viewEnd();
}
if (ctx.exp2) {
let cm1 = V(1);
let cm1 = viewStart(1);
{
if (cm1) {
lastEl = E(0, 'span', null, null, ['foo', '']);
e();
lastEl = elementStart(0, 'span', null, null, ['foo', '']);
elementEnd();
}
}
v();
viewEnd();
}
}
cr();
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
containerRefreshEnd();
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as any);
expect(query.length).toBe(0);
const qList = (cmptInstance.query as any);
expect(qList.length).toBe(0);
cmptInstance.exp2 = true;
detectChanges(cmptInstance);
expect(query.length).toBe(1);
expect(query.last.nativeElement).toBe(lastEl);
expect(qList.length).toBe(1);
expect(qList.last.nativeElement).toBe(lastEl);
cmptInstance.exp1 = true;
detectChanges(cmptInstance);
expect(query.length).toBe(2);
expect(query.first.nativeElement).toBe(firstEl);
expect(query.last.nativeElement).toBe(lastEl);
expect(qList.length).toBe(2);
expect(qList.first.nativeElement).toBe(firstEl);
expect(qList.last.nativeElement).toBe(lastEl);
});
it('should add results from embedded views in the correct order - nested views', () => {
@ -719,55 +720,55 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo'], true, QUERY_READ_FROM_NODE);
C(1);
query(0, ['foo'], true, QUERY_READ_FROM_NODE);
container(1);
}
cR(1);
containerRefreshStart(1);
{
if (ctx.exp1) {
let cm1 = V(0);
let cm1 = viewStart(0);
{
if (cm1) {
firstEl = E(0, 'div', null, null, ['foo', '']);
e();
C(1);
firstEl = elementStart(0, 'div', null, null, ['foo', '']);
elementEnd();
container(1);
}
cR(1);
containerRefreshStart(1);
{
if (ctx.exp2) {
let cm2 = V(0);
let cm2 = viewStart(0);
{
if (cm2) {
lastEl = E(0, 'span', null, null, ['foo', '']);
e();
lastEl = elementStart(0, 'span', null, null, ['foo', '']);
elementEnd();
}
}
v();
viewEnd();
}
}
cr();
containerRefreshEnd();
}
v();
viewEnd();
}
}
cr();
qR(tmp = m<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
containerRefreshEnd();
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
const query = (cmptInstance.query as any);
expect(query.length).toBe(0);
const qList = (cmptInstance.query as any);
expect(qList.length).toBe(0);
cmptInstance.exp1 = true;
detectChanges(cmptInstance);
expect(query.length).toBe(1);
expect(query.first.nativeElement).toBe(firstEl);
expect(qList.length).toBe(1);
expect(qList.first.nativeElement).toBe(firstEl);
cmptInstance.exp2 = true;
detectChanges(cmptInstance);
expect(query.length).toBe(2);
expect(query.first.nativeElement).toBe(firstEl);
expect(query.last.nativeElement).toBe(lastEl);
expect(qList.length).toBe(2);
expect(qList.first.nativeElement).toBe(firstEl);
expect(qList.last.nativeElement).toBe(lastEl);
});
it('should support combination of deep and shallow queries', () => {
@ -783,28 +784,28 @@ describe('query', () => {
const Cmpt = createComponent('cmpt', function(ctx: any, cm: boolean) {
let tmp: any;
if (cm) {
Q(0, ['foo'], true, QUERY_READ_FROM_NODE);
Q(1, ['foo'], false, QUERY_READ_FROM_NODE);
C(2);
E(3, 'span', null, null, ['foo', '']);
e();
query(0, ['foo'], true, QUERY_READ_FROM_NODE);
query(1, ['foo'], false, QUERY_READ_FROM_NODE);
container(2);
elementStart(3, 'span', null, null, ['foo', '']);
elementEnd();
}
cR(2);
containerRefreshStart(2);
{
if (ctx.exp) {
let cm1 = V(0);
let cm1 = viewStart(0);
{
if (cm1) {
E(0, 'div', null, null, ['foo', '']);
e();
elementStart(0, 'div', null, null, ['foo', '']);
elementEnd();
}
}
v();
viewEnd();
}
}
cr();
qR(tmp = m<QueryList<any>>(0)) && (ctx.deep = tmp as QueryList<any>);
qR(tmp = m<QueryList<any>>(1)) && (ctx.shallow = tmp as QueryList<any>);
containerRefreshEnd();
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.deep = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(1)) && (ctx.shallow = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -841,17 +842,17 @@ describe('query', () => {
});
// initial refresh, the query should be dirty
qR(queryList);
queryRefresh(queryList);
expect(changes).toBe(1);
// refresh without setting dirty - no emit
qR(queryList);
queryRefresh(queryList);
expect(changes).toBe(1);
// refresh with setting dirty - emit
queryList.setDirty();
qR(queryList);
queryRefresh(queryList);
expect(changes).toBe(2);
});

View File

@ -10,7 +10,8 @@ import {AnimationEvent} from '@angular/animations';
import {MockAnimationDriver, MockAnimationPlayer} from '@angular/animations/browser/testing';
import {RendererType2, ViewEncapsulation} from '../../src/core';
import {E, L, T, b, defineComponent, detectChanges, e, p, r} from '../../src/render3/index';
import {defineComponent, detectChanges} from '../../src/render3/index';
import {bind, componentRefresh, elementEnd, elementProperty, elementStart, listener, text} from '../../src/render3/instructions';
import {createRendererType2} from '../../src/view/index';
import {getAnimationRendererFactory2, getRendererFactory2} from './imported_renderer2';
@ -34,7 +35,7 @@ describe('renderer factory lifecycle', () => {
template: function(ctx: SomeComponent, cm: boolean) {
logs.push('component');
if (cm) {
T(0, 'foo');
text(0, 'foo');
}
},
factory: () => new SomeComponent
@ -55,19 +56,19 @@ describe('renderer factory lifecycle', () => {
function Template(ctx: any, cm: boolean) {
logs.push('function');
if (cm) {
T(0, 'bar');
text(0, 'bar');
}
}
function TemplateWithComponent(ctx: any, cm: boolean) {
logs.push('function_with_component');
if (cm) {
T(0, 'bar');
E(1, SomeComponent);
e();
text(0, 'bar');
elementStart(1, SomeComponent);
elementEnd();
}
SomeComponent.ngComponentDef.h(2, 1);
r(2, 1);
componentRefresh(2, 1);
}
beforeEach(() => { logs = []; });
@ -126,7 +127,7 @@ describe('animation renderer factory', () => {
tag: 'some-component',
template: function(ctx: SomeComponent, cm: boolean) {
if (cm) {
T(0, 'foo');
text(0, 'foo');
}
},
factory: () => new SomeComponent
@ -143,15 +144,15 @@ describe('animation renderer factory', () => {
tag: 'some-component',
template: function(ctx: SomeComponentWithAnimation, cm: boolean) {
if (cm) {
E(0, 'div');
elementStart(0, 'div');
{
L('@myAnimation.start', ctx.callback.bind(ctx));
L('@myAnimation.done', ctx.callback.bind(ctx));
T(1, 'foo');
listener('@myAnimation.start', ctx.callback.bind(ctx));
listener('@myAnimation.done', ctx.callback.bind(ctx));
text(1, 'foo');
}
e();
elementEnd();
}
p(0, '@myAnimation', b(ctx.exp));
elementProperty(0, '@myAnimation', bind(ctx.exp));
},
factory: () => new SomeComponentWithAnimation,
rendererType: createRendererType2({

View File

@ -7,7 +7,8 @@
*/
import {TemplateRef, ViewContainerRef} from '../../src/core';
import {C, T, b, cR, cr, defineComponent, defineDirective, injectTemplateRef, injectViewContainerRef, m, r, t} from '../../src/render3/index';
import {defineComponent, defineDirective, injectTemplateRef, injectViewContainerRef} from '../../src/render3/index';
import {bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, memory, text, textBinding} from '../../src/render3/instructions';
import {renderComponent, toHtml} from './render_util';
@ -32,17 +33,17 @@ describe('ViewContainerRef', () => {
if (cm) {
const subTemplate = (ctx: any, cm: boolean) => {
if (cm) {
T(0);
text(0);
}
t(0, b(ctx.$implicit));
textBinding(0, bind(ctx.$implicit));
};
C(0, [TestDirective], subTemplate);
container(0, [TestDirective], subTemplate);
}
cR(0);
cmp.testDir = m(1) as TestDirective;
containerRefreshStart(0);
cmp.testDir = memory(1) as TestDirective;
TestDirective.ngDirectiveDef.h(1, 0);
r(1, 0);
cr();
componentRefresh(1, 0);
containerRefreshEnd();
},
});
}