Skip to content

Commit

Permalink
refactor(core): rename synthetic host property and listener instructi…
Browse files Browse the repository at this point in the history
…ons (#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
  • Loading branch information
AndrewKushnir committed Jul 21, 2020
1 parent eae13e4 commit d72b1e4
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 34 deletions.
8 changes: 4 additions & 4 deletions goldens/public-api/core/core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,6 @@ export declare type ɵɵComponentDefWithMeta<T, Selector extends String, ExportA
[key: string]: string;
}, 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 ɵɵCopyDefinitionFeature(definition: ɵDirectiveDef<any> | ɵComponentDef<any>): void;
Expand Down Expand Up @@ -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 ɵɵ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 ɵɵtemplateRefExtractor(tNode: TNode, currentView: ɵangular_packages_core_core_bp): TemplateRef<unknown> | null;
Expand All @@ -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 ɵɵ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 const PACKAGE_ROOT_URL: InjectionToken<string>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ describe('compiler compliance', () => {
hostVars: 14,
hostBindings: function MyComponent_HostBindings(rf, ctx) {
if (rf & 2) {
$r3$.ɵɵupdateSyntheticHostBinding("@expansionHeight",
$r3$.ɵɵsyntheticHostProperty("@expansionHeight",
$r3$.ɵɵpureFunction2(5, $_c1$, ctx.getExpandedState(),
$r3$.ɵɵpureFunction2(2, $_c0$, ctx.collapsedHeight, ctx.expandedHeight)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ describe('compiler compliance: bindings', () => {
hostBindings: function MyDirective_HostBindings(rf, ctx) {
if (rf & 2) {
$r3$.ɵɵupdateSyntheticHostBinding("@expand", ctx.expandedState)("@fadeOut", true)("@shrink", ctx.isSmall);
$r3$.ɵɵsyntheticHostProperty("@expand", ctx.expandedState)("@fadeOut", true)("@shrink", ctx.isSmall);
}
}
`;
Expand Down Expand Up @@ -1173,7 +1173,7 @@ describe('compiler compliance: bindings', () => {
hostBindings: function MyComponent_HostBindings(rf, ctx) {
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(); });
}
}
`;
Expand Down Expand Up @@ -1211,7 +1211,7 @@ describe('compiler compliance: bindings', () => {
hostBindings: function MyComponent_HostBindings(rf, ctx) {
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(); });
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,10 @@ describe('compiler compliance: styling', () => {
hostVars: 1,
hostBindings: function MyAnimDir_HostBindings(rf, ctx) {
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(); });
} if (rf & 2) {
$r3$.ɵɵupdateSyntheticHostBinding("@myAnim", ctx.myAnimState);
$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$.ɵɵsyntheticHostProperty("@myAnim", ctx.myAnimState);
}
}
Expand Down Expand Up @@ -2083,7 +2084,7 @@ describe('compiler compliance: styling', () => {
hostBindings: function MyDir_HostBindings(rf, ctx) {
if (rf & 2) {
$r3$.ɵɵhostProperty("title", ctx.title);
$r3$.ɵɵupdateSyntheticHostBinding("@anim",
$r3$.ɵɵsyntheticHostProperty("@anim",
$r3$.ɵɵpureFunction2(7, _c1, ctx._animValue,
$r3$.ɵɵpureFunction2(4, _c0, ctx._animParam1, ctx._animParam2)));
$r3$.ɵɵclassProp("foo", ctx.foo);
Expand Down
8 changes: 4 additions & 4 deletions packages/compiler/src/render3/r3_identifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export class Identifiers {
static select: o.ExternalReference = {name: 'ɵɵselect', moduleName: CORE};
static advance: o.ExternalReference = {name: 'ɵɵadvance', moduleName: CORE};

static updateSyntheticHostBinding:
o.ExternalReference = {name: 'ɵɵupdateSyntheticHostBinding', moduleName: CORE};
static syntheticHostProperty:
o.ExternalReference = {name: 'ɵɵsyntheticHostProperty', moduleName: CORE};

static componentHostSyntheticListener:
o.ExternalReference = {name: 'ɵɵcomponentHostSyntheticListener', moduleName: CORE};
static syntheticHostListener:
o.ExternalReference = {name: 'ɵɵsyntheticHostListener', moduleName: CORE};

static attribute: o.ExternalReference = {name: 'ɵɵattribute', moduleName: CORE};

Expand Down
9 changes: 4 additions & 5 deletions packages/compiler/src/render3/view/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ function createHostBindingsFunction(
propertyBindings.push(instructionParams);
} else if (instruction === R3.attribute) {
attributeBindings.push(instructionParams);
} else if (instruction === R3.updateSyntheticHostBinding) {
} else if (instruction === R3.syntheticHostProperty) {
syntheticHostBindings.push(instructionParams);
} else {
updateStatements.push(o.importExpr(instruction).callFn(instructionParams).toStmt());
Expand All @@ -657,7 +657,7 @@ function createHostBindingsFunction(

if (syntheticHostBindings.length > 0) {
updateStatements.push(
chainedInstruction(R3.updateSyntheticHostBinding, syntheticHostBindings).toStmt());
chainedInstruction(R3.syntheticHostProperty, syntheticHostBindings).toStmt());
}

// since we're dealing with directives/components and both have hostBinding
Expand Down Expand Up @@ -738,7 +738,7 @@ function getBindingNameAndInstruction(binding: ParsedProperty):
// 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
// compatibility instruction available for this purpose.
instruction = R3.updateSyntheticHostBinding;
instruction = R3.syntheticHostProperty;
} else {
instruction = R3.hostProperty;
}
Expand Down Expand Up @@ -768,8 +768,7 @@ function createHostListeners(eventBindings: ParsedEvent[], name?: string): o.Sta
});

if (syntheticListeners.length > 0) {
instructions.push(
chainedInstruction(R3.componentHostSyntheticListener, syntheticListeners).toStmt());
instructions.push(chainedInstruction(R3.syntheticHostListener, syntheticListeners).toStmt());
}

if (listeners.length > 0) {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/core_render3_private_export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export {
ɵɵclassMapInterpolateV,
ɵɵclassProp,
ɵɵComponentDefWithMeta,
ɵɵcomponentHostSyntheticListener,
ɵɵcontentQuery,
ɵɵCopyDefinitionFeature,
ɵɵdefineComponent,
Expand Down Expand Up @@ -227,6 +226,8 @@ export {
ɵɵstylePropInterpolate7,
ɵɵstylePropInterpolate8,
ɵɵstylePropInterpolateV,
ɵɵsyntheticHostListener,
ɵɵsyntheticHostProperty,
ɵɵtemplate,
ɵɵtemplateRefExtractor,
ɵɵtext,
Expand All @@ -240,7 +241,6 @@ export {
ɵɵtextInterpolate7,
ɵɵtextInterpolate8,
ɵɵtextInterpolateV,
ɵɵupdateSyntheticHostBinding,
ɵɵviewQuery,
} from './render3/index';
export {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/render3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export {
ɵɵclassMapInterpolateV,

ɵɵclassProp,
ɵɵcomponentHostSyntheticListener,

ɵɵdirectiveInject,

Expand Down Expand Up @@ -113,6 +112,9 @@ export {
ɵɵstylePropInterpolate8,
ɵɵstylePropInterpolateV,

ɵɵsyntheticHostListener,
ɵɵsyntheticHostProperty,

ɵɵtemplate,

ɵɵtext,
Expand All @@ -126,8 +128,6 @@ export {
ɵɵtextInterpolate7,
ɵɵtextInterpolate8,
ɵɵtextInterpolateV,

ɵɵupdateSyntheticHostBinding,
} from './instructions/all';
export {RenderFlags} from './interfaces/definition';
export {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/render3/instructions/host_property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ export function ɵɵhostProperty<T>(
*
* @codeGenApi
*/
export function ɵɵupdateSyntheticHostBinding<T>(
export function ɵɵsyntheticHostProperty<T>(
propName: string, value: T|NO_CHANGE,
sanitizer?: SanitizerFn|null): typeof ɵɵupdateSyntheticHostBinding {
sanitizer?: SanitizerFn|null): typeof ɵɵsyntheticHostProperty {
const lView = getLView();
const bindingIndex = nextBindingIndex();
if (bindingUpdated(lView, bindingIndex, value)) {
Expand All @@ -75,5 +75,5 @@ export function ɵɵupdateSyntheticHostBinding<T>(
elementPropertyInternal(tView, tNode, lView, propName, value, renderer, sanitizer, true);
ngDevMode && storePropertyBindingMetadata(tView.data, tNode, propName, bindingIndex);
}
return ɵɵupdateSyntheticHostBinding;
return ɵɵsyntheticHostProperty;
}
6 changes: 3 additions & 3 deletions packages/core/src/render3/instructions/listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ export function ɵɵlistener(
*
* @codeGenApi
*/
export function ɵɵcomponentHostSyntheticListener(
export function ɵɵsyntheticHostListener(
eventName: string, listenerFn: (e?: any) => any, useCapture = false,
eventTargetResolver?: GlobalTargetResolver): typeof ɵɵcomponentHostSyntheticListener {
eventTargetResolver?: GlobalTargetResolver): typeof ɵɵsyntheticHostListener {
const tNode = getPreviousOrParentTNode();
const lView = getLView();
const tView = getTView();
const currentDef = getCurrentDirectiveDef(tView.data);
const renderer = loadComponentRenderer(currentDef, tNode, lView);
listenerInternal(
tView, lView, renderer, tNode, eventName, listenerFn, useCapture, eventTargetResolver);
return ɵɵcomponentHostSyntheticListener;
return ɵɵsyntheticHostListener;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/render3/jit/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export const angularCoreEnv: {[name: string]: Function} =
'ɵɵrestoreView': r3.ɵɵrestoreView,
'ɵɵlistener': r3.ɵɵlistener,
'ɵɵprojection': r3.ɵɵprojection,
'ɵɵupdateSyntheticHostBinding': r3.ɵɵupdateSyntheticHostBinding,
'ɵɵcomponentHostSyntheticListener': r3.ɵɵcomponentHostSyntheticListener,
'ɵɵsyntheticHostProperty': r3.ɵɵsyntheticHostProperty,
'ɵɵsyntheticHostListener': r3.ɵɵsyntheticHostListener,
'ɵɵpipeBind1': r3.ɵɵpipeBind1,
'ɵɵpipeBind2': r3.ɵɵpipeBind2,
'ɵɵpipeBind3': r3.ɵɵpipeBind3,
Expand Down

0 comments on commit d72b1e4

Please sign in to comment.