refactor(core): rename synthetic host property and listener instructions (#37145)

This commit updates synthetic host property and listener instruction names to better align with other instructions.
The `ɵɵupdateSyntheticHostBinding` instruction was renamed to `ɵɵsyntheticHostProperty` (to match the `ɵɵhostProperty`
instruction name) and `ɵɵcomponentHostSyntheticListener` was renamed to `ɵɵsyntheticHostListener` since this
instruction is generated for both Components and Directives (so 'component' is removed from the name).
This PR is a followup after PR #35568.

PR Close #37145
This commit is contained in:
Andrew Kushnir 2020-05-15 15:33:00 -07:00
parent eae13e42f3
commit d72b1e44c6
11 changed files with 34 additions and 34 deletions

View File

@ -723,8 +723,6 @@ export declare type ɵɵComponentDefWithMeta<T, Selector extends String, ExportA
[key: string]: string; [key: string]: string;
}, QueryFields extends string[], NgContentSelectors extends string[]> = ɵComponentDef<T>; }, QueryFields extends string[], NgContentSelectors extends string[]> = ɵComponentDef<T>;
export declare function ɵɵcomponentHostSyntheticListener(eventName: string, listenerFn: (e?: any) => any, useCapture?: boolean, eventTargetResolver?: GlobalTargetResolver): typeof ɵɵcomponentHostSyntheticListener;
export declare function ɵɵcontentQuery<T>(directiveIndex: number, predicate: Type<any> | InjectionToken<unknown> | string[], descend: boolean, read?: any): void; export declare function ɵɵcontentQuery<T>(directiveIndex: number, predicate: Type<any> | InjectionToken<unknown> | string[], descend: boolean, read?: any): void;
export declare function ɵɵCopyDefinitionFeature(definition: ɵDirectiveDef<any> | ɵComponentDef<any>): void; export declare function ɵɵCopyDefinitionFeature(definition: ɵDirectiveDef<any> | ɵComponentDef<any>): void;
@ -1054,6 +1052,10 @@ export declare function ɵɵstylePropInterpolate8(prop: string, prefix: string,
export declare function ɵɵstylePropInterpolateV(prop: string, values: any[], valueSuffix?: string | null): typeof ɵɵstylePropInterpolateV; export declare function ɵɵstylePropInterpolateV(prop: string, values: any[], valueSuffix?: string | null): typeof ɵɵstylePropInterpolateV;
export declare function ɵɵsyntheticHostListener(eventName: string, listenerFn: (e?: any) => any, useCapture?: boolean, eventTargetResolver?: GlobalTargetResolver): typeof ɵɵsyntheticHostListener;
export declare function ɵɵsyntheticHostProperty<T>(propName: string, value: T | ɵNO_CHANGE, sanitizer?: SanitizerFn | null): typeof ɵɵsyntheticHostProperty;
export declare function ɵɵtemplate(index: number, templateFn: ComponentTemplate<any> | null, decls: number, vars: number, tagName?: string | null, attrsIndex?: number | null, localRefsIndex?: number | null, localRefExtractor?: LocalRefExtractor): void; export declare function ɵɵtemplate(index: number, templateFn: ComponentTemplate<any> | null, decls: number, vars: number, tagName?: string | null, attrsIndex?: number | null, localRefsIndex?: number | null, localRefExtractor?: LocalRefExtractor): void;
export declare function ɵɵtemplateRefExtractor(tNode: TNode, currentView: ɵangular_packages_core_core_bp): TemplateRef<unknown> | null; export declare function ɵɵtemplateRefExtractor(tNode: TNode, currentView: ɵangular_packages_core_core_bp): TemplateRef<unknown> | null;
@ -1080,8 +1082,6 @@ export declare function ɵɵtextInterpolate8(prefix: string, v0: any, i0: string
export declare function ɵɵtextInterpolateV(values: any[]): typeof ɵɵtextInterpolateV; export declare function ɵɵtextInterpolateV(values: any[]): typeof ɵɵtextInterpolateV;
export declare function ɵɵupdateSyntheticHostBinding<T>(propName: string, value: T | ɵNO_CHANGE, sanitizer?: SanitizerFn | null): typeof ɵɵupdateSyntheticHostBinding;
export declare function ɵɵviewQuery<T>(predicate: Type<any> | InjectionToken<unknown> | string[], descend: boolean, read?: any): void; export declare function ɵɵviewQuery<T>(predicate: Type<any> | InjectionToken<unknown> | string[], descend: boolean, read?: any): void;
export declare const PACKAGE_ROOT_URL: InjectionToken<string>; export declare const PACKAGE_ROOT_URL: InjectionToken<string>;

View File

@ -434,7 +434,7 @@ describe('compiler compliance', () => {
hostVars: 14, hostVars: 14,
hostBindings: function MyComponent_HostBindings(rf, ctx) { hostBindings: function MyComponent_HostBindings(rf, ctx) {
if (rf & 2) { if (rf & 2) {
$r3$.ɵɵupdateSyntheticHostBinding("@expansionHeight", $r3$.ɵɵsyntheticHostProperty("@expansionHeight",
$r3$.ɵɵpureFunction2(5, $_c1$, ctx.getExpandedState(), $r3$.ɵɵpureFunction2(5, $_c1$, ctx.getExpandedState(),
$r3$.ɵɵpureFunction2(2, $_c0$, ctx.collapsedHeight, ctx.expandedHeight) $r3$.ɵɵpureFunction2(2, $_c0$, ctx.collapsedHeight, ctx.expandedHeight)
) )

View File

@ -1000,7 +1000,7 @@ describe('compiler compliance: bindings', () => {
hostBindings: function MyDirective_HostBindings(rf, ctx) { hostBindings: function MyDirective_HostBindings(rf, ctx) {
if (rf & 2) { if (rf & 2) {
$r3$.ɵɵupdateSyntheticHostBinding("@expand", ctx.expandedState)("@fadeOut", true)("@shrink", ctx.isSmall); $r3$.ɵɵsyntheticHostProperty("@expand", ctx.expandedState)("@fadeOut", true)("@shrink", ctx.isSmall);
} }
} }
`; `;
@ -1173,7 +1173,7 @@ describe('compiler compliance: bindings', () => {
hostBindings: function MyComponent_HostBindings(rf, ctx) { hostBindings: function MyComponent_HostBindings(rf, ctx) {
if (rf & 1) { if (rf & 1) {
$r3$.ɵɵcomponentHostSyntheticListener("@animation.done", function MyComponent_animation_animation_done_HostBindingHandler() { return ctx.done(); })("@animation.start", function MyComponent_animation_animation_start_HostBindingHandler() { return ctx.start(); }); $r3$.ɵɵsyntheticHostListener("@animation.done", function MyComponent_animation_animation_done_HostBindingHandler() { return ctx.done(); })("@animation.start", function MyComponent_animation_animation_start_HostBindingHandler() { return ctx.start(); });
} }
} }
`; `;
@ -1211,7 +1211,7 @@ describe('compiler compliance: bindings', () => {
hostBindings: function MyComponent_HostBindings(rf, ctx) { hostBindings: function MyComponent_HostBindings(rf, ctx) {
if (rf & 1) { if (rf & 1) {
$r3$.ɵɵcomponentHostSyntheticListener("@animation.done", function MyComponent_animation_animation_done_HostBindingHandler() { return ctx.done(); })("@animation.start", function MyComponent_animation_animation_start_HostBindingHandler() { return ctx.start(); }); $r3$.ɵɵsyntheticHostListener("@animation.done", function MyComponent_animation_animation_done_HostBindingHandler() { return ctx.done(); })("@animation.start", function MyComponent_animation_animation_start_HostBindingHandler() { return ctx.start(); });
$r3$.ɵɵlistener("mousedown", function MyComponent_mousedown_HostBindingHandler() { return ctx.mousedown(); })("mouseup", function MyComponent_mouseup_HostBindingHandler() { return ctx.mouseup(); })("click", function MyComponent_click_HostBindingHandler() { return ctx.click(); }); $r3$.ɵɵlistener("mousedown", function MyComponent_mousedown_HostBindingHandler() { return ctx.mousedown(); })("mouseup", function MyComponent_mouseup_HostBindingHandler() { return ctx.mouseup(); })("click", function MyComponent_click_HostBindingHandler() { return ctx.click(); });
} }
} }

View File

@ -336,9 +336,10 @@ describe('compiler compliance: styling', () => {
hostVars: 1, hostVars: 1,
hostBindings: function MyAnimDir_HostBindings(rf, ctx) { hostBindings: function MyAnimDir_HostBindings(rf, ctx) {
if (rf & 1) { if (rf & 1) {
$r3$.ɵɵcomponentHostSyntheticListener("@myAnim.start", function MyAnimDir_animation_myAnim_start_HostBindingHandler() { return ctx.onStart(); })("@myAnim.done", function MyAnimDir_animation_myAnim_done_HostBindingHandler() { return ctx.onDone(); }); $r3$.ɵɵsyntheticHostListener("@myAnim.start", function MyAnimDir_animation_myAnim_start_HostBindingHandler() { return ctx.onStart(); })("@myAnim.done", function MyAnimDir_animation_myAnim_done_HostBindingHandler() { return ctx.onDone(); });
} if (rf & 2) { }
$r3$.ɵɵupdateSyntheticHostBinding("@myAnim", ctx.myAnimState); if (rf & 2) {
$r3$.ɵɵsyntheticHostProperty("@myAnim", ctx.myAnimState);
} }
} }
@ -2083,7 +2084,7 @@ describe('compiler compliance: styling', () => {
hostBindings: function MyDir_HostBindings(rf, ctx) { hostBindings: function MyDir_HostBindings(rf, ctx) {
if (rf & 2) { if (rf & 2) {
$r3$.ɵɵhostProperty("title", ctx.title); $r3$.ɵɵhostProperty("title", ctx.title);
$r3$.ɵɵupdateSyntheticHostBinding("@anim", $r3$.ɵɵsyntheticHostProperty("@anim",
$r3$.ɵɵpureFunction2(7, _c1, ctx._animValue, $r3$.ɵɵpureFunction2(7, _c1, ctx._animValue,
$r3$.ɵɵpureFunction2(4, _c0, ctx._animParam1, ctx._animParam2))); $r3$.ɵɵpureFunction2(4, _c0, ctx._animParam1, ctx._animParam2)));
$r3$.ɵɵclassProp("foo", ctx.foo); $r3$.ɵɵclassProp("foo", ctx.foo);

View File

@ -32,11 +32,11 @@ export class Identifiers {
static select: o.ExternalReference = {name: 'ɵɵselect', moduleName: CORE}; static select: o.ExternalReference = {name: 'ɵɵselect', moduleName: CORE};
static advance: o.ExternalReference = {name: 'ɵɵadvance', moduleName: CORE}; static advance: o.ExternalReference = {name: 'ɵɵadvance', moduleName: CORE};
static updateSyntheticHostBinding: static syntheticHostProperty:
o.ExternalReference = {name: 'ɵɵupdateSyntheticHostBinding', moduleName: CORE}; o.ExternalReference = {name: 'ɵɵsyntheticHostProperty', moduleName: CORE};
static componentHostSyntheticListener: static syntheticHostListener:
o.ExternalReference = {name: 'ɵɵcomponentHostSyntheticListener', moduleName: CORE}; o.ExternalReference = {name: 'ɵɵsyntheticHostListener', moduleName: CORE};
static attribute: o.ExternalReference = {name: 'ɵɵattribute', moduleName: CORE}; static attribute: o.ExternalReference = {name: 'ɵɵattribute', moduleName: CORE};

View File

@ -640,7 +640,7 @@ function createHostBindingsFunction(
propertyBindings.push(instructionParams); propertyBindings.push(instructionParams);
} else if (instruction === R3.attribute) { } else if (instruction === R3.attribute) {
attributeBindings.push(instructionParams); attributeBindings.push(instructionParams);
} else if (instruction === R3.updateSyntheticHostBinding) { } else if (instruction === R3.syntheticHostProperty) {
syntheticHostBindings.push(instructionParams); syntheticHostBindings.push(instructionParams);
} else { } else {
updateStatements.push(o.importExpr(instruction).callFn(instructionParams).toStmt()); updateStatements.push(o.importExpr(instruction).callFn(instructionParams).toStmt());
@ -657,7 +657,7 @@ function createHostBindingsFunction(
if (syntheticHostBindings.length > 0) { if (syntheticHostBindings.length > 0) {
updateStatements.push( updateStatements.push(
chainedInstruction(R3.updateSyntheticHostBinding, syntheticHostBindings).toStmt()); chainedInstruction(R3.syntheticHostProperty, syntheticHostBindings).toStmt());
} }
// since we're dealing with directives/components and both have hostBinding // since we're dealing with directives/components and both have hostBinding
@ -738,7 +738,7 @@ function getBindingNameAndInstruction(binding: ParsedProperty):
// host bindings that have a synthetic property (e.g. @foo) should always be rendered // host bindings that have a synthetic property (e.g. @foo) should always be rendered
// in the context of the component and not the parent. Therefore there is a special // in the context of the component and not the parent. Therefore there is a special
// compatibility instruction available for this purpose. // compatibility instruction available for this purpose.
instruction = R3.updateSyntheticHostBinding; instruction = R3.syntheticHostProperty;
} else { } else {
instruction = R3.hostProperty; instruction = R3.hostProperty;
} }
@ -768,8 +768,7 @@ function createHostListeners(eventBindings: ParsedEvent[], name?: string): o.Sta
}); });
if (syntheticListeners.length > 0) { if (syntheticListeners.length > 0) {
instructions.push( instructions.push(chainedInstruction(R3.syntheticHostListener, syntheticListeners).toStmt());
chainedInstruction(R3.componentHostSyntheticListener, syntheticListeners).toStmt());
} }
if (listeners.length > 0) { if (listeners.length > 0) {

View File

@ -124,7 +124,6 @@ export {
ɵɵclassMapInterpolateV, ɵɵclassMapInterpolateV,
ɵɵclassProp, ɵɵclassProp,
ɵɵComponentDefWithMeta, ɵɵComponentDefWithMeta,
ɵɵcomponentHostSyntheticListener,
ɵɵcontentQuery, ɵɵcontentQuery,
ɵɵCopyDefinitionFeature, ɵɵCopyDefinitionFeature,
ɵɵdefineComponent, ɵɵdefineComponent,
@ -227,6 +226,8 @@ export {
ɵɵstylePropInterpolate7, ɵɵstylePropInterpolate7,
ɵɵstylePropInterpolate8, ɵɵstylePropInterpolate8,
ɵɵstylePropInterpolateV, ɵɵstylePropInterpolateV,
ɵɵsyntheticHostListener,
ɵɵsyntheticHostProperty,
ɵɵtemplate, ɵɵtemplate,
ɵɵtemplateRefExtractor, ɵɵtemplateRefExtractor,
ɵɵtext, ɵɵtext,
@ -240,7 +241,6 @@ export {
ɵɵtextInterpolate7, ɵɵtextInterpolate7,
ɵɵtextInterpolate8, ɵɵtextInterpolate8,
ɵɵtextInterpolateV, ɵɵtextInterpolateV,
ɵɵupdateSyntheticHostBinding,
ɵɵviewQuery, ɵɵviewQuery,
} from './render3/index'; } from './render3/index';
export { export {

View File

@ -48,7 +48,6 @@ export {
ɵɵclassMapInterpolateV, ɵɵclassMapInterpolateV,
ɵɵclassProp, ɵɵclassProp,
ɵɵcomponentHostSyntheticListener,
ɵɵdirectiveInject, ɵɵdirectiveInject,
@ -113,6 +112,9 @@ export {
ɵɵstylePropInterpolate8, ɵɵstylePropInterpolate8,
ɵɵstylePropInterpolateV, ɵɵstylePropInterpolateV,
ɵɵsyntheticHostListener,
ɵɵsyntheticHostProperty,
ɵɵtemplate, ɵɵtemplate,
ɵɵtext, ɵɵtext,
@ -126,8 +128,6 @@ export {
ɵɵtextInterpolate7, ɵɵtextInterpolate7,
ɵɵtextInterpolate8, ɵɵtextInterpolate8,
ɵɵtextInterpolateV, ɵɵtextInterpolateV,
ɵɵupdateSyntheticHostBinding,
} from './instructions/all'; } from './instructions/all';
export {RenderFlags} from './interfaces/definition'; export {RenderFlags} from './interfaces/definition';
export { export {

View File

@ -62,9 +62,9 @@ export function ɵɵhostProperty<T>(
* *
* @codeGenApi * @codeGenApi
*/ */
export function ɵɵupdateSyntheticHostBinding<T>( export function ɵɵsyntheticHostProperty<T>(
propName: string, value: T|NO_CHANGE, propName: string, value: T|NO_CHANGE,
sanitizer?: SanitizerFn|null): typeof ɵɵupdateSyntheticHostBinding { sanitizer?: SanitizerFn|null): typeof ɵɵsyntheticHostProperty {
const lView = getLView(); const lView = getLView();
const bindingIndex = nextBindingIndex(); const bindingIndex = nextBindingIndex();
if (bindingUpdated(lView, bindingIndex, value)) { if (bindingUpdated(lView, bindingIndex, value)) {
@ -75,5 +75,5 @@ export function ɵɵupdateSyntheticHostBinding<T>(
elementPropertyInternal(tView, tNode, lView, propName, value, renderer, sanitizer, true); elementPropertyInternal(tView, tNode, lView, propName, value, renderer, sanitizer, true);
ngDevMode && storePropertyBindingMetadata(tView.data, tNode, propName, bindingIndex); ngDevMode && storePropertyBindingMetadata(tView.data, tNode, propName, bindingIndex);
} }
return ɵɵupdateSyntheticHostBinding; return ɵɵsyntheticHostProperty;
} }

View File

@ -68,9 +68,9 @@ export function ɵɵlistener(
* *
* @codeGenApi * @codeGenApi
*/ */
export function ɵɵcomponentHostSyntheticListener( export function ɵɵsyntheticHostListener(
eventName: string, listenerFn: (e?: any) => any, useCapture = false, eventName: string, listenerFn: (e?: any) => any, useCapture = false,
eventTargetResolver?: GlobalTargetResolver): typeof ɵɵcomponentHostSyntheticListener { eventTargetResolver?: GlobalTargetResolver): typeof ɵɵsyntheticHostListener {
const tNode = getPreviousOrParentTNode(); const tNode = getPreviousOrParentTNode();
const lView = getLView(); const lView = getLView();
const tView = getTView(); const tView = getTView();
@ -78,7 +78,7 @@ export function ɵɵcomponentHostSyntheticListener(
const renderer = loadComponentRenderer(currentDef, tNode, lView); const renderer = loadComponentRenderer(currentDef, tNode, lView);
listenerInternal( listenerInternal(
tView, lView, renderer, tNode, eventName, listenerFn, useCapture, eventTargetResolver); tView, lView, renderer, tNode, eventName, listenerFn, useCapture, eventTargetResolver);
return ɵɵcomponentHostSyntheticListener; return ɵɵsyntheticHostListener;
} }
/** /**

View File

@ -75,8 +75,8 @@ export const angularCoreEnv: {[name: string]: Function} =
'ɵɵrestoreView': r3.ɵɵrestoreView, 'ɵɵrestoreView': r3.ɵɵrestoreView,
'ɵɵlistener': r3.ɵɵlistener, 'ɵɵlistener': r3.ɵɵlistener,
'ɵɵprojection': r3.ɵɵprojection, 'ɵɵprojection': r3.ɵɵprojection,
'ɵɵupdateSyntheticHostBinding': r3.ɵɵupdateSyntheticHostBinding, 'ɵɵsyntheticHostProperty': r3.ɵɵsyntheticHostProperty,
'ɵɵcomponentHostSyntheticListener': r3.ɵɵcomponentHostSyntheticListener, 'ɵɵsyntheticHostListener': r3.ɵɵsyntheticHostListener,
'ɵɵpipeBind1': r3.ɵɵpipeBind1, 'ɵɵpipeBind1': r3.ɵɵpipeBind1,
'ɵɵpipeBind2': r3.ɵɵpipeBind2, 'ɵɵpipeBind2': r3.ɵɵpipeBind2,
'ɵɵpipeBind3': r3.ɵɵpipeBind3, 'ɵɵpipeBind3': r3.ɵɵpipeBind3,