From 811679a5830ad4b9970648de704976acb1ef16b1 Mon Sep 17 00:00:00 2001 From: Kara Erickson Date: Mon, 22 Jan 2018 19:52:06 -0800 Subject: [PATCH] refactor(ivy): remove unnecessary Comp.r function (#21650) PR Close #21650 --- modules/benchmarks/src/tree/render3/tree.ts | 6 +- .../test/render3/r3_view_compiler_spec.ts | 6 +- .../core/src/core_render3_private_export.ts | 1 + packages/core/src/render3/definition.ts | 5 - packages/core/src/render3/instructions.ts | 41 ++-- .../core/src/render3/interfaces/definition.ts | 28 +-- .../test/render3/compiler_canonical_spec.ts | 6 +- packages/core/test/render3/component_spec.ts | 8 +- packages/core/test/render3/content_spec.ts | 48 ++--- packages/core/test/render3/directive_spec.ts | 7 +- .../core/test/render3/integration_spec.ts | 14 +- packages/core/test/render3/lifecycle_spec.ts | 180 +++++++++--------- packages/core/test/render3/listeners_spec.ts | 6 +- packages/core/test/render3/outputs_spec.ts | 22 +-- packages/core/test/render3/properties_spec.ts | 6 +- .../test/render3/renderer_factory_spec.ts | 4 +- 16 files changed, 179 insertions(+), 209 deletions(-) diff --git a/modules/benchmarks/src/tree/render3/tree.ts b/modules/benchmarks/src/tree/render3/tree.ts index 91465ebaff..228b2e0b3c 100644 --- a/modules/benchmarks/src/tree/render3/tree.ts +++ b/modules/benchmarks/src/tree/render3/tree.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {ɵC as C, ɵE as E, ɵT as T, ɵV as V, ɵb as b, ɵb1 as b1, ɵcR as cR, ɵcr as cr, ɵdefineComponent as defineComponent, ɵdetectChanges as _detectChanges, ɵe as e, ɵp as p, ɵs as s, ɵt as t, ɵv as v} from '@angular/core'; +import {ɵC as C, ɵE as E, ɵT as T, ɵV as V, ɵb as b, ɵb1 as b1, ɵcR as cR, ɵcr as cr, ɵdefineComponent as defineComponent, ɵdetectChanges as _detectChanges, ɵe as e, ɵp as p, ɵr as r, ɵs as s, ɵt as t, ɵv as v} from '@angular/core'; import {ComponentDef} from '@angular/core/src/render3/interfaces/definition'; import {TreeNode, buildTree, emptyTree} from '../util'; @@ -59,7 +59,7 @@ export class TreeComponent { } p(0, 'data', b(ctx.data.left)); TreeComponent.ngComponentDef.h(1, 0); - TreeComponent.ngComponentDef.r(1, 0); + r(1, 0); } v(); } @@ -76,7 +76,7 @@ export class TreeComponent { } p(0, 'data', b(ctx.data.right)); TreeComponent.ngComponentDef.h(1, 0); - TreeComponent.ngComponentDef.r(1, 0); + r(1, 0); } v(); } diff --git a/packages/compiler/test/render3/r3_view_compiler_spec.ts b/packages/compiler/test/render3/r3_view_compiler_spec.ts index 57b4342953..d3573814aa 100644 --- a/packages/compiler/test/render3/r3_view_compiler_spec.ts +++ b/packages/compiler/test/render3/r3_view_compiler_spec.ts @@ -205,8 +205,8 @@ describe('r3_view_compiler', () => { IDENT.ɵe(); IDENT.ɵT(3, '!'); } - ChildComponent.ngComponentDef.r(1, 0); - SomeDirective.ngDirectiveDef.r(2, 0); + r(1, 0); + r(2, 0); } }); `; @@ -267,7 +267,7 @@ describe('r3_view_compiler', () => { } const IDENT = IDENT.ɵm(1); IDENT.ɵcR(2); - IfDirective.ngDirectiveDef.r(3,2); + r(3,2); IDENT.ɵcr(); function MyComponent_IfDirective_Template_2(ctx0: IDENT, cm: IDENT) { diff --git a/packages/core/src/core_render3_private_export.ts b/packages/core/src/core_render3_private_export.ts index a1306fec04..46d4049f35 100644 --- a/packages/core/src/core_render3_private_export.ts +++ b/packages/core/src/core_render3_private_export.ts @@ -34,5 +34,6 @@ export { s as ɵs, t as ɵt, v as ɵv, + r as ɵr, } from './render3/index'; // clang-format on diff --git a/packages/core/src/render3/definition.ts b/packages/core/src/render3/definition.ts index ef326d4391..1238a83540 100644 --- a/packages/core/src/render3/definition.ts +++ b/packages/core/src/render3/definition.ts @@ -40,11 +40,6 @@ export function defineComponent(componentDefinition: ComponentDefArgs): Co n: componentDefinition.factory, tag: (componentDefinition as ComponentDefArgs).tag || null !, template: (componentDefinition as ComponentDefArgs).template || null !, - r: componentDefinition.refresh || (componentDefinition.template ? - function(d: number, e: number) { - componentRefresh(d, e, componentDefinition.template); - } : - noop), h: componentDefinition.hostBindings || noop, inputs: invertObject(componentDefinition.inputs), outputs: invertObject(componentDefinition.outputs), diff --git a/packages/core/src/render3/instructions.ts b/packages/core/src/render3/instructions.ts index 22e0647d3c..69ab5589bb 100644 --- a/packages/core/src/render3/instructions.ts +++ b/packages/core/src/render3/instructions.ts @@ -337,8 +337,8 @@ export function renderComponentOrTemplate( template(componentOrContext !, creationMode); } else { // Element was stored at 0 and directive was stored at 1 in renderComponent - // so to refresh the component, r() needs to be called with (1, 0) - (componentOrContext.constructor as ComponentType).ngComponentDef.r(1, 0); + // so to refresh the component, refresh() needs to be called with (1, 0) + componentRefresh(1, 0); } } finally { if (rendererFactory.end) { @@ -1161,28 +1161,27 @@ export function viewEnd(): void { * * @param directiveIndex * @param elementIndex - * @param template */ -export const componentRefresh: - (directiveIndex: number, elementIndex: number, template: ComponentTemplate) => - void = function( - directiveIndex: number, elementIndex: number, template: ComponentTemplate) { - ngDevMode && assertDataInRange(elementIndex); - const element = data ![elementIndex] as LElementNode; - ngDevMode && assertNodeOfPossibleTypes(element, LNodeFlags.Element, LNodeFlags.Container); - ngDevMode && assertNotEqual(element.data, null, 'isComponent'); - ngDevMode && assertDataInRange(directiveIndex); - const hostView = element.data !; - ngDevMode && assertNotEqual(hostView, null, 'hostView'); +export function componentRefresh(directiveIndex: number, elementIndex: number): void { executeInitHooks(currentView); executeContentHooks(currentView); - const directive = data[directiveIndex]; - const oldView = enterView(hostView, element); - try { - template(directive, creationMode); - } finally { - refreshDynamicChildren(); - leaveView(oldView); + const template = (tData[directiveIndex] as ComponentDef).template; + if (template != null) { + ngDevMode && assertDataInRange(elementIndex); + const element = data ![elementIndex] as LElementNode; + ngDevMode && assertNodeType(element, LNodeFlags.Element); + ngDevMode && assertNotEqual(element.data, null, 'isComponent'); + ngDevMode && assertDataInRange(directiveIndex); + const directive = data[directiveIndex]; + const hostView = element.data !; + ngDevMode && assertNotEqual(hostView, null, 'hostView'); + const oldView = enterView(hostView, element); + try { + template(directive, creationMode); + } finally { + refreshDynamicChildren(); + leaveView(oldView); + } } }; diff --git a/packages/core/src/render3/interfaces/definition.ts b/packages/core/src/render3/interfaces/definition.ts index 777686a28a..9d4f666bcf 100644 --- a/packages/core/src/render3/interfaces/definition.ts +++ b/packages/core/src/render3/interfaces/definition.ts @@ -67,18 +67,6 @@ export interface DirectiveDef { */ n(): T; - /** - * Refreshes the view of the component. Also calls lifecycle hooks like - * ngAfterViewInit, if they are defined on the component. - * - * NOTE: this property is short (1 char) because it is used in component - * templates which is sensitive to size. - * - * @param directiveIndex index of the directive in the containing template - * @param elementIndex index of an host element for a given directive. - */ - r(directiveIndex: number, elementIndex: number): void; - /** * Refreshes host bindings on the associated directive. Also calls lifecycle hooks * like ngOnInit and ngDoCheck, if they are defined on the directive. @@ -94,18 +82,6 @@ export interface DirectiveDef { } export interface ComponentDef extends DirectiveDef { - /** - * Refreshes the view of the component. Also calls lifecycle hooks like - * ngAfterViewInit, if they are defined on the component. - * - * NOTE: this property is short (1 char) because it is used in - * component templates which is sensitive to size. - * - * @param directiveIndex index of the directive in the containing template - * @param elementIndex index of an host element for a given component. - */ - r(directiveIndex: number, elementIndex: number): void; - /** * The tag name which should be used by the component. * @@ -142,19 +118,17 @@ export interface LifecycleHooksMap { export interface DirectiveDefArgs { type: Type; factory: () => T; - refresh?: (directiveIndex: number, elementIndex: number) => void; inputs?: {[P in keyof T]?: string}; outputs?: {[P in keyof T]?: string}; methods?: {[P in keyof T]?: string}; features?: DirectiveDefFeature[]; + hostBindings?: (directiveIndex: number, elementIndex: number) => void; exportAs?: string; } export interface ComponentDefArgs extends DirectiveDefArgs { tag: string; template: ComponentTemplate; - refresh?: (directiveIndex: number, elementIndex: number) => void; - hostBindings?: (directiveIndex: number, elementIndex: number) => void; features?: ComponentDefFeature[]; rendererType?: RendererType2; } diff --git a/packages/core/test/render3/compiler_canonical_spec.ts b/packages/core/test/render3/compiler_canonical_spec.ts index 0e7ce8dc44..e18af8f4f4 100644 --- a/packages/core/test/render3/compiler_canonical_spec.ts +++ b/packages/core/test/render3/compiler_canonical_spec.ts @@ -98,8 +98,8 @@ describe('compiler specification', () => { r3.e(); r3.T(3, '!'); } - ChildComponent.ngComponentDef.r(1, 0); - SomeDirective.ngDirectiveDef.r(2, 0); + r3.r(1, 0); + r3.r(2, 0); } }); // /NORMATIVE @@ -146,7 +146,7 @@ describe('compiler specification', () => { } let foo = r3.m(1); r3.cR(2); - IfDirective.ngDirectiveDef.r(3, 2); + r3.r(3, 2); r3.cr(); function C1(ctx1: any, cm: boolean) { diff --git a/packages/core/test/render3/component_spec.ts b/packages/core/test/render3/component_spec.ts index 1ceac8fd6a..fac4e51796 100644 --- a/packages/core/test/render3/component_spec.ts +++ b/packages/core/test/render3/component_spec.ts @@ -7,7 +7,7 @@ */ import {ViewEncapsulation} from '../../src/core'; -import {E, T, b, defineComponent, e, markDirty, t} from '../../src/render3/index'; +import {E, T, b, defineComponent, e, markDirty, r, t} from '../../src/render3/index'; import {createRendererType2} from '../../src/view/index'; import {getRendererFactory2} from './imported_renderer2'; @@ -72,7 +72,7 @@ describe('encapsulation', () => { e(); } EncapsulatedComponent.ngComponentDef.h(1, 0); - EncapsulatedComponent.ngComponentDef.r(1, 0); + r(1, 0); }, factory: () => new WrapperComponent, }); @@ -89,7 +89,7 @@ describe('encapsulation', () => { e(); } LeafComponent.ngComponentDef.h(2, 1); - LeafComponent.ngComponentDef.r(2, 1); + r(2, 1); }, factory: () => new EncapsulatedComponent, rendererType: @@ -137,7 +137,7 @@ describe('encapsulation', () => { e(); } LeafComponentwith.ngComponentDef.h(1, 0); - LeafComponentwith.ngComponentDef.r(1, 0); + r(1, 0); }, factory: () => new WrapperComponentWith, rendererType: diff --git a/packages/core/test/render3/content_spec.ts b/packages/core/test/render3/content_spec.ts index f1166ece34..322eaa37c5 100644 --- a/packages/core/test/render3/content_spec.ts +++ b/packages/core/test/render3/content_spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {C, E, P, T, V, cR, cr, detectChanges, e, m, pD, v} from '../../src/render3/index'; +import {C, E, P, T, V, cR, cr, detectChanges, e, m, pD, r, v} from '../../src/render3/index'; import {createComponent, renderComponent, toHtml} from './render_util'; @@ -35,7 +35,7 @@ describe('content projection', () => { e(); } Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); expect(toHtml(parent)).toEqual('
content
'); @@ -55,7 +55,7 @@ describe('content projection', () => { e(); } Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); expect(toHtml(parent)).toEqual('content'); @@ -77,7 +77,7 @@ describe('content projection', () => { { P(3, 0); } e(); GrandChild.ngComponentDef.h(2, 1); - GrandChild.ngComponentDef.r(2, 1); + r(2, 1); } }); const Parent = createComponent('parent', function(ctx: any, cm: boolean) { @@ -92,7 +92,7 @@ describe('content projection', () => { e(); } Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); expect(toHtml(parent)) @@ -133,8 +133,8 @@ describe('content projection', () => { } Child.ngComponentDef.h(1, 0); ProjectedComp.ngComponentDef.h(3, 2); - ProjectedComp.ngComponentDef.r(3, 2); - Child.ngComponentDef.r(1, 0); + r(3, 2); + r(1, 0); }); const parent = renderComponent(Parent); expect(toHtml(parent)) @@ -171,7 +171,7 @@ describe('content projection', () => { } cr(); Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); expect(toHtml(parent)).toEqual('
()
'); @@ -207,7 +207,7 @@ describe('content projection', () => { } cr(); Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); expect(toHtml(parent)).toEqual(''); @@ -256,7 +256,7 @@ describe('content projection', () => { } cr(); Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); expect(toHtml(parent)).toEqual('
(else)
'); @@ -314,7 +314,7 @@ describe('content projection', () => { e(); } Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); expect(toHtml(parent)).toEqual('
content
'); @@ -367,7 +367,7 @@ describe('content projection', () => { e(); } Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); expect(toHtml(parent)).toEqual('
content
'); @@ -404,7 +404,7 @@ describe('content projection', () => { e(); } Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); expect(toHtml(parent)).toEqual('
content
'); @@ -462,7 +462,7 @@ describe('content projection', () => { e(); } Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); expect(toHtml(parent)).toEqual('content
'); @@ -511,7 +511,7 @@ describe('content projection', () => { e(); } Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); @@ -557,7 +557,7 @@ describe('content projection', () => { e(); } Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); @@ -603,7 +603,7 @@ describe('content projection', () => { e(); } Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); @@ -649,7 +649,7 @@ describe('content projection', () => { e(); } Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); @@ -696,7 +696,7 @@ describe('content projection', () => { e(); } Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); @@ -743,8 +743,8 @@ describe('content projection', () => { } e(); } - Child.ngComponentDef.h(0, 0); - Child.ngComponentDef.r(0, 0); + Child.ngComponentDef.h(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); @@ -792,7 +792,7 @@ describe('content projection', () => { } e(); GrandChild.ngComponentDef.h(2, 1); - GrandChild.ngComponentDef.r(2, 1); + r(2, 1); } }); @@ -814,7 +814,7 @@ describe('content projection', () => { e(); } Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); @@ -863,7 +863,7 @@ describe('content projection', () => { } cr(); Child.ngComponentDef.h(1, 0); - Child.ngComponentDef.r(1, 0); + r(1, 0); }); const parent = renderComponent(Parent); expect(toHtml(parent)).toEqual('
content
'); diff --git a/packages/core/test/render3/directive_spec.ts b/packages/core/test/render3/directive_spec.ts index 60c82ff794..dc763478ef 100644 --- a/packages/core/test/render3/directive_spec.ts +++ b/packages/core/test/render3/directive_spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {E, b, defineDirective, e, m, p} from '../../src/render3/index'; +import {E, b, defineDirective, e, m, p, r} from '../../src/render3/index'; import {renderToHtml} from './render_util'; @@ -22,7 +22,7 @@ describe('directive', () => { static ngDirectiveDef = defineDirective({ type: Directive, factory: () => directiveInstance = new Directive, - refresh: (directiveIndex: number, elementIndex: number) => { + hostBindings: (directiveIndex: number, elementIndex: number) => { p(elementIndex, 'className', b(m(directiveIndex).klass)); } }); @@ -33,7 +33,8 @@ describe('directive', () => { E(0, 'span', null, [Directive]); e(); } - Directive.ngDirectiveDef.r(1, 0); + Directive.ngDirectiveDef.h(1, 0); + r(1, 0); } expect(renderToHtml(Template, {})).toEqual(''); diff --git a/packages/core/test/render3/integration_spec.ts b/packages/core/test/render3/integration_spec.ts index 289fb5618e..2939216058 100644 --- a/packages/core/test/render3/integration_spec.ts +++ b/packages/core/test/render3/integration_spec.ts @@ -234,7 +234,7 @@ describe('render3 integration test', () => { e(); } TodoComponent.ngComponentDef.h(1, 0); - TodoComponent.ngComponentDef.r(1, 0); + r(1, 0); } expect(renderToHtml(Template, null)).toEqual('

Todo one

'); @@ -248,7 +248,7 @@ describe('render3 integration test', () => { T(2, 'two'); } TodoComponent.ngComponentDef.h(1, 0); - TodoComponent.ngComponentDef.r(1, 0); + r(1, 0); } expect(renderToHtml(Template, null)).toEqual('

Todo one

two'); }); @@ -267,8 +267,8 @@ describe('render3 integration test', () => { } TodoComponent.ngComponentDef.h(1, 0); TodoComponent.ngComponentDef.h(3, 2); - TodoComponent.ngComponentDef.r(1, 0); - TodoComponent.ngComponentDef.r(3, 2); + r(1, 0); + r(3, 2); } expect(renderToHtml(Template, null)) .toEqual('

Todo one

Todo one

'); @@ -303,7 +303,7 @@ describe('render3 integration test', () => { e(); } TodoComponentHostBinding.ngComponentDef.h(1, 0); - TodoComponentHostBinding.ngComponentDef.r(1, 0); + r(1, 0); } expect(renderToHtml(Template, {})).toEqual('one'); @@ -336,7 +336,7 @@ describe('render3 integration test', () => { e(); } MyComp.ngComponentDef.h(1, 0); - MyComp.ngComponentDef.r(1, 0); + r(1, 0); } expect(renderToHtml(Template, null)).toEqual('

Bess

'); @@ -383,7 +383,7 @@ describe('render3 integration test', () => { } p(0, 'condition', b(ctx.condition)); MyComp.ngComponentDef.h(1, 0); - MyComp.ngComponentDef.r(1, 0); + r(1, 0); } expect(renderToHtml(Template, {condition: true})).toEqual('
text
'); diff --git a/packages/core/test/render3/lifecycle_spec.ts b/packages/core/test/render3/lifecycle_spec.ts index a628641511..927b7d7038 100644 --- a/packages/core/test/render3/lifecycle_spec.ts +++ b/packages/core/test/render3/lifecycle_spec.ts @@ -20,7 +20,7 @@ describe('lifecycles', () => { } p(0, 'val', b(ctx.val)); type.ngComponentDef.h(1, 0); - type.ngComponentDef.r(1, 0); + r(1, 0); }; } @@ -68,7 +68,7 @@ describe('lifecycles', () => { } p(0, 'val', b(ctx.val)); Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); } renderToHtml(Template, {val: '1'}); @@ -90,7 +90,7 @@ describe('lifecycles', () => { e(); } Parent.ngComponentDef.h(1, 0); - Parent.ngComponentDef.r(1, 0); + r(1, 0); } renderToHtml(Template, {}); @@ -116,8 +116,8 @@ describe('lifecycles', () => { p(2, 'val', 2); Parent.ngComponentDef.h(1, 0); Parent.ngComponentDef.h(3, 2); - Parent.ngComponentDef.r(1, 0); - Parent.ngComponentDef.r(3, 2); + r(1, 0); + r(3, 2); } renderToHtml(Template, {}); @@ -144,7 +144,7 @@ describe('lifecycles', () => { e(); } Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); v(); } } @@ -175,8 +175,8 @@ describe('lifecycles', () => { } Comp.ngComponentDef.h(1, 0); ProjectedComp.ngComponentDef.h(3, 2); - ProjectedComp.ngComponentDef.r(3, 2); - Comp.ngComponentDef.r(1, 0); + r(3, 2); + r(1, 0); } renderToHtml(Template, {}); @@ -209,10 +209,10 @@ describe('lifecycles', () => { ProjectedComp.ngComponentDef.h(3, 2); Comp.ngComponentDef.h(5, 4); ProjectedComp.ngComponentDef.h(7, 6); - ProjectedComp.ngComponentDef.r(3, 2); - Comp.ngComponentDef.r(1, 0); - ProjectedComp.ngComponentDef.r(7, 6); - Comp.ngComponentDef.r(5, 4); + r(3, 2); + r(1, 0); + r(7, 6); + r(5, 4); } renderToHtml(Template, {}); @@ -232,7 +232,7 @@ describe('lifecycles', () => { e(); } Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); } renderToHtml(Template, {}); @@ -273,13 +273,13 @@ describe('lifecycles', () => { } p(0, 'val', j); Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); v(); } } cr(); - Comp.ngComponentDef.r(1, 0); - Comp.ngComponentDef.r(4, 3); + r(1, 0); + r(4, 3); } renderToHtml(Template, {}); @@ -319,13 +319,13 @@ describe('lifecycles', () => { } p(0, 'val', j); Parent.ngComponentDef.h(1, 0); - Parent.ngComponentDef.r(1, 0); + r(1, 0); v(); } } cr(); - Parent.ngComponentDef.r(1, 0); - Parent.ngComponentDef.r(4, 3); + r(1, 0); + r(4, 3); } renderToHtml(Template, {}); @@ -375,7 +375,7 @@ describe('lifecycles', () => { e(); } Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); } renderToHtml(Template, {}); @@ -397,7 +397,7 @@ describe('lifecycles', () => { e(); } Parent.ngComponentDef.h(1, 0); - Parent.ngComponentDef.r(1, 0); + r(1, 0); } renderToHtml(Template, {}); @@ -412,7 +412,7 @@ describe('lifecycles', () => { e(); } Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); } renderToHtml(Template, {}); @@ -449,7 +449,7 @@ describe('lifecycles', () => { } p(1, 'val', b(ctx.val)); Comp.ngComponentDef.h(2, 1); - Comp.ngComponentDef.r(2, 1); + r(2, 1); }); let ProjectedComp = createAfterContentInitComp('projected', (ctx: any, cm: boolean) => { @@ -487,7 +487,7 @@ describe('lifecycles', () => { e(); } Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); } renderToHtml(Template, {}); @@ -516,7 +516,7 @@ describe('lifecycles', () => { e(); } Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); v(); } } @@ -546,7 +546,7 @@ describe('lifecycles', () => { e(); } Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); } renderToHtml(Template, {}); @@ -570,7 +570,7 @@ describe('lifecycles', () => { e(); } Parent.ngComponentDef.h(1, 0); - Parent.ngComponentDef.r(1, 0); + r(1, 0); } renderToHtml(Template, {}); @@ -597,8 +597,8 @@ describe('lifecycles', () => { p(3, 'val', 2); Parent.ngComponentDef.h(1, 0); Parent.ngComponentDef.h(4, 3); - Parent.ngComponentDef.r(1, 0); - Parent.ngComponentDef.r(4, 3); + r(1, 0); + r(4, 3); } renderToHtml(Template, {}); @@ -628,8 +628,8 @@ describe('lifecycles', () => { } Parent.ngComponentDef.h(1, 0); ProjectedComp.ngComponentDef.h(3, 2); - ProjectedComp.ngComponentDef.r(3, 2); - Parent.ngComponentDef.r(1, 0); + r(3, 2); + r(1, 0); } renderToHtml(Template, {}); @@ -675,10 +675,10 @@ describe('lifecycles', () => { ProjectedComp.ngComponentDef.h(3, 2); Parent.ngComponentDef.h(6, 5); ProjectedComp.ngComponentDef.h(8, 7); - ProjectedComp.ngComponentDef.r(3, 2); - Parent.ngComponentDef.r(1, 0); - ProjectedComp.ngComponentDef.r(8, 7); - Parent.ngComponentDef.r(6, 5); + r(3, 2); + r(1, 0); + r(8, 7); + r(6, 5); } renderToHtml(Template, {}); @@ -717,13 +717,13 @@ describe('lifecycles', () => { } p(0, 'val', i); Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); v(); } } cr(); - Comp.ngComponentDef.r(1, 0); - Comp.ngComponentDef.r(5, 4); + r(1, 0); + r(5, 4); } renderToHtml(Template, {}); @@ -754,13 +754,13 @@ describe('lifecycles', () => { } p(0, 'val', i); Parent.ngComponentDef.h(1, 0); - Parent.ngComponentDef.r(1, 0); + r(1, 0); v(); } } cr(); - Parent.ngComponentDef.r(1, 0); - Parent.ngComponentDef.r(5, 4); + r(1, 0); + r(5, 4); } it('should be called in correct order in a for loop with children', () => { @@ -788,7 +788,7 @@ describe('lifecycles', () => { e(); } Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); } renderToHtml(Template, {}); @@ -854,7 +854,7 @@ describe('lifecycles', () => { e(); } Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); } renderToHtml(Template, {}); @@ -882,7 +882,7 @@ describe('lifecycles', () => { e(); } Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); v(); } } @@ -912,7 +912,7 @@ describe('lifecycles', () => { e(); } Parent.ngComponentDef.h(1, 0); - Parent.ngComponentDef.r(1, 0); + r(1, 0); } renderToHtml(Template, {}); @@ -938,8 +938,8 @@ describe('lifecycles', () => { p(2, 'val', 2); Parent.ngComponentDef.h(1, 0); Parent.ngComponentDef.h(3, 2); - Parent.ngComponentDef.r(1, 0); - Parent.ngComponentDef.r(3, 2); + r(1, 0); + r(3, 2); } renderToHtml(Template, {}); expect(events).toEqual(['comp1', 'comp2', 'parent1', 'parent2']); @@ -963,8 +963,8 @@ describe('lifecycles', () => { } Comp.ngComponentDef.h(1, 0); ProjectedComp.ngComponentDef.h(3, 2); - ProjectedComp.ngComponentDef.r(3, 2); - Comp.ngComponentDef.r(1, 0); + r(3, 2); + r(1, 0); } renderToHtml(Template, {}); @@ -1003,10 +1003,10 @@ describe('lifecycles', () => { ProjectedComp.ngComponentDef.h(3, 2); Comp.ngComponentDef.h(5, 4); ProjectedComp.ngComponentDef.h(7, 6); - ProjectedComp.ngComponentDef.r(3, 2); - Comp.ngComponentDef.r(1, 0); - ProjectedComp.ngComponentDef.r(7, 6); - Comp.ngComponentDef.r(5, 4); + r(3, 2); + r(1, 0); + r(7, 6); + r(5, 4); } renderToHtml(Template, {}); @@ -1032,8 +1032,8 @@ describe('lifecycles', () => { p(2, 'val', b(ctx.val)); Comp.ngComponentDef.h(1, 0); ProjectedComp.ngComponentDef.h(3, 2); - ProjectedComp.ngComponentDef.r(3, 2); - Comp.ngComponentDef.r(1, 0); + r(3, 2); + r(1, 0); }); /** @@ -1051,8 +1051,8 @@ describe('lifecycles', () => { p(2, 'val', 2); ParentComp.ngComponentDef.h(1, 0); ParentComp.ngComponentDef.h(3, 2); - ParentComp.ngComponentDef.r(1, 0); - ParentComp.ngComponentDef.r(3, 2); + r(1, 0); + r(3, 2); } renderToHtml(Template, {}); @@ -1088,13 +1088,13 @@ describe('lifecycles', () => { } p(0, 'val', i); Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); v(); } } cr(); - Comp.ngComponentDef.r(1, 0); - Comp.ngComponentDef.r(4, 3); + r(1, 0); + r(4, 3); } renderToHtml(Template, {}); @@ -1131,13 +1131,13 @@ describe('lifecycles', () => { } p(0, 'val', i); Parent.ngComponentDef.h(1, 0); - Parent.ngComponentDef.r(1, 0); + r(1, 0); v(); } } cr(); - Parent.ngComponentDef.r(1, 0); - Parent.ngComponentDef.r(4, 3); + r(1, 0); + r(4, 3); } renderToHtml(Template, {}); @@ -1157,7 +1157,7 @@ describe('lifecycles', () => { e(); } Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); } renderToHtml(Template, {}); @@ -1176,7 +1176,7 @@ describe('lifecycles', () => { } p(0, 'val', b(ctx.myVal)); Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); } renderToHtml(Template, {myVal: 5}); @@ -1215,13 +1215,13 @@ describe('lifecycles', () => { } p(0, 'val', i); Parent.ngComponentDef.h(1, 0); - Parent.ngComponentDef.r(1, 0); + r(1, 0); v(); } } cr(); - Parent.ngComponentDef.r(1, 0); - Parent.ngComponentDef.r(4, 3); + r(1, 0); + r(4, 3); } renderToHtml(Template, {}); @@ -1284,7 +1284,7 @@ describe('lifecycles', () => { e(); } Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); v(); } } @@ -1321,8 +1321,8 @@ describe('lifecycles', () => { p(2, 'val', b('2')); Comp.ngComponentDef.h(1, 0); Comp.ngComponentDef.h(3, 2); - Comp.ngComponentDef.r(1, 0); - Comp.ngComponentDef.r(3, 2); + r(1, 0); + r(3, 2); v(); } } @@ -1355,7 +1355,7 @@ describe('lifecycles', () => { e(); } Parent.ngComponentDef.h(1, 0); - Parent.ngComponentDef.r(1, 0); + r(1, 0); v(); } } @@ -1383,7 +1383,7 @@ describe('lifecycles', () => { e(); } Parent.ngComponentDef.h(1, 0); - Parent.ngComponentDef.r(1, 0); + r(1, 0); }); function Template(ctx: any, cm: boolean) { @@ -1398,7 +1398,7 @@ describe('lifecycles', () => { e(); } Grandparent.ngComponentDef.h(1, 0); - Grandparent.ngComponentDef.r(1, 0); + r(1, 0); v(); } } @@ -1452,10 +1452,10 @@ describe('lifecycles', () => { ProjectedComp.ngComponentDef.h(3, 2); Comp.ngComponentDef.h(5, 4); ProjectedComp.ngComponentDef.h(7, 6); - ProjectedComp.ngComponentDef.r(3, 2); - Comp.ngComponentDef.r(1, 0); - ProjectedComp.ngComponentDef.r(7, 6); - Comp.ngComponentDef.r(5, 4); + r(3, 2); + r(1, 0); + r(7, 6); + r(5, 4); v(); } } @@ -1507,13 +1507,13 @@ describe('lifecycles', () => { } p(0, 'val', b('2')); Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); v(); } } cr(); - Comp.ngComponentDef.r(1, 0); - Comp.ngComponentDef.r(4, 3); + r(1, 0); + r(4, 3); v(); } } @@ -1583,13 +1583,13 @@ describe('lifecycles', () => { } p(0, 'val', b(j)); Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); v(); } } cr(); - Comp.ngComponentDef.r(1, 0); - Comp.ngComponentDef.r(4, 3); + r(1, 0); + r(4, 3); v(); } } @@ -1658,7 +1658,7 @@ describe('lifecycles', () => { e(); } Comp.ngComponentDef.h(3, 2); - Comp.ngComponentDef.r(3, 2); + r(3, 2); v(); } } @@ -1737,8 +1737,8 @@ describe('lifecycles', () => { p(2, 'val', 2); Comp.ngComponentDef.h(1, 0); Comp.ngComponentDef.h(3, 2); - Comp.ngComponentDef.r(1, 0); - Comp.ngComponentDef.r(3, 2); + r(1, 0); + r(3, 2); } renderToHtml(Template, {}); @@ -1767,7 +1767,7 @@ describe('lifecycles', () => { } p(0, 'val', b(ctx.val)); Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); }); /** @@ -1785,8 +1785,8 @@ describe('lifecycles', () => { p(2, 'val', 2); Parent.ngComponentDef.h(1, 0); Parent.ngComponentDef.h(3, 2); - Parent.ngComponentDef.r(1, 0); - Parent.ngComponentDef.r(3, 2); + r(1, 0); + r(3, 2); } renderToHtml(Template, {}); diff --git a/packages/core/test/render3/listeners_spec.ts b/packages/core/test/render3/listeners_spec.ts index 41955afbf9..c7d8f55e86 100644 --- a/packages/core/test/render3/listeners_spec.ts +++ b/packages/core/test/render3/listeners_spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {C, E, L, T, V, cR, cr, defineComponent, e, v} from '../../src/render3/index'; +import {C, E, L, T, V, cR, cr, defineComponent, e, r, v} from '../../src/render3/index'; import {containerEl, renderComponent, renderToHtml} from './render_util'; @@ -208,8 +208,8 @@ describe('event listeners', () => { } MyComp.ngComponentDef.h(2, 1); MyComp.ngComponentDef.h(4, 3); - MyComp.ngComponentDef.r(2, 1); - MyComp.ngComponentDef.r(4, 3); + r(2, 1); + r(4, 3); v(); } } diff --git a/packages/core/test/render3/outputs_spec.ts b/packages/core/test/render3/outputs_spec.ts index f10eacc7ee..161aeeaeea 100644 --- a/packages/core/test/render3/outputs_spec.ts +++ b/packages/core/test/render3/outputs_spec.ts @@ -8,7 +8,7 @@ import {EventEmitter} from '@angular/core'; -import {C, E, L, T, V, b, cR, cr, defineComponent, defineDirective, e, p, v} from '../../src/render3/index'; +import {C, E, L, T, V, b, cR, cr, defineComponent, defineDirective, e, p, r, v} from '../../src/render3/index'; import {containerEl, renderToHtml} from './render_util'; @@ -49,7 +49,7 @@ describe('outputs', () => { e(); } ButtonToggle.ngComponentDef.h(1, 0); - ButtonToggle.ngComponentDef.r(1, 0); + r(1, 0); } let counter = 0; @@ -75,7 +75,7 @@ describe('outputs', () => { e(); } ButtonToggle.ngComponentDef.h(1, 0); - ButtonToggle.ngComponentDef.r(1, 0); + r(1, 0); } let counter = 0; @@ -99,7 +99,7 @@ describe('outputs', () => { e(); } ButtonToggle.ngComponentDef.h(1, 0); - ButtonToggle.ngComponentDef.r(1, 0); + r(1, 0); } const ctx = {counter: 0}; @@ -133,7 +133,7 @@ describe('outputs', () => { e(); } ButtonToggle.ngComponentDef.h(1, 0); - ButtonToggle.ngComponentDef.r(1, 0); + r(1, 0); v(); } } @@ -183,7 +183,7 @@ describe('outputs', () => { e(); } ButtonToggle.ngComponentDef.h(1, 0); - ButtonToggle.ngComponentDef.r(1, 0); + r(1, 0); v(); } } @@ -252,8 +252,8 @@ describe('outputs', () => { } ButtonToggle.ngComponentDef.h(3, 2); DestroyComp.ngComponentDef.h(5, 4); - ButtonToggle.ngComponentDef.r(3, 2); - DestroyComp.ngComponentDef.r(5, 4); + r(3, 2); + r(5, 4); v(); } } @@ -326,7 +326,7 @@ describe('outputs', () => { e(); } ButtonToggle.ngComponentDef.h(1, 0); - ButtonToggle.ngComponentDef.r(1, 0); + r(1, 0); } let counter = 0; @@ -358,7 +358,7 @@ describe('outputs', () => { } p(0, 'change', b(ctx.change)); ButtonToggle.ngComponentDef.h(1, 0); - ButtonToggle.ngComponentDef.r(1, 0); + r(1, 0); } let counter = 0; @@ -401,7 +401,7 @@ describe('outputs', () => { e(); } ButtonToggle.ngComponentDef.h(1, 0); - ButtonToggle.ngComponentDef.r(1, 0); + r(1, 0); v(); } else { if (V(1)) { diff --git a/packages/core/test/render3/properties_spec.ts b/packages/core/test/render3/properties_spec.ts index f6aea699a5..db333fb3f5 100644 --- a/packages/core/test/render3/properties_spec.ts +++ b/packages/core/test/render3/properties_spec.ts @@ -8,7 +8,7 @@ import {EventEmitter} from '@angular/core'; -import {C, E, L, T, V, b, b1, cR, cr, defineComponent, defineDirective, e, m, p, t, v} from '../../src/render3/index'; +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 {renderToHtml} from './render_util'; @@ -157,7 +157,7 @@ describe('elementProperty', () => { } p(0, 'id', b(ctx.id)); Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); } expect(renderToHtml(Template, {id: 1})).toEqual(``); @@ -502,7 +502,7 @@ describe('elementProperty', () => { e(); } Comp.ngComponentDef.h(1, 0); - Comp.ngComponentDef.r(1, 0); + r(1, 0); v(); } } diff --git a/packages/core/test/render3/renderer_factory_spec.ts b/packages/core/test/render3/renderer_factory_spec.ts index 83a266000a..fad14ce376 100644 --- a/packages/core/test/render3/renderer_factory_spec.ts +++ b/packages/core/test/render3/renderer_factory_spec.ts @@ -10,7 +10,7 @@ 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} from '../../src/render3/index'; +import {E, L, T, b, defineComponent, detectChanges, e, p, r} from '../../src/render3/index'; import {createRendererType2} from '../../src/view/index'; import {getAnimationRendererFactory2, getRendererFactory2} from './imported_renderer2'; @@ -67,7 +67,7 @@ describe('renderer factory lifecycle', () => { e(); } SomeComponent.ngComponentDef.h(2, 1); - SomeComponent.ngComponentDef.r(2, 1); + r(2, 1); } beforeEach(() => { logs = []; });