Skip to content

Commit b4e6802

Browse files
benleshmhevery
authored andcommitted
refactor(ivy): add ɵɵupdateSyntheticHostBinding command (angular#30670)
- Refactors `ɵɵcomponentHostSyntheticProperty` into `ɵɵupdateSyntheticHostBinding`, to better align it with other new instructions. PR Close angular#30670
1 parent 680d385 commit b4e6802

File tree

9 files changed

+22
-32
lines changed

9 files changed

+22
-32
lines changed

packages/compiler-cli/test/compliance/r3_compiler_compliance_spec.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,19 +444,17 @@ describe('compiler compliance', () => {
444444
$r3$.ɵɵallocHostVars(14);
445445
}
446446
if (rf & 2) {
447-
$r3$.ɵɵcomponentHostSyntheticProperty(elIndex, "@expansionHeight",
448-
$r3$.ɵɵbind(
447+
$r3$.ɵɵupdateSyntheticHostBinding("@expansionHeight",
449448
$r3$.ɵɵpureFunction2(5, $_c1$, ctx.getExpandedState(),
450449
$r3$.ɵɵpureFunction2(2, $_c0$, ctx.collapsedHeight, ctx.expandedHeight)
451450
)
452-
), null, true
451+
, null, true
453452
);
454-
$r3$.ɵɵcomponentHostSyntheticProperty(elIndex, "@expansionWidth",
455-
$r3$.ɵɵbind(
453+
$r3$.ɵɵupdateSyntheticHostBinding("@expansionWidth",
456454
$r3$.ɵɵpureFunction2(11, $_c1$, ctx.getExpandedState(),
457455
$r3$.ɵɵpureFunction2(8, $_c2$, ctx.collapsedWidth, ctx.expandedWidth)
458456
)
459-
), null, true
457+
, null, true
460458
);
461459
}
462460
},

packages/compiler-cli/test/compliance/r3_view_compiler_styling_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ describe('compiler compliance: styling', () => {
350350
$r3$.ɵɵcomponentHostSyntheticListener("@myAnim.start", function MyAnimDir_animation_myAnim_start_HostBindingHandler($event) { return ctx.onStart(); });
351351
$r3$.ɵɵcomponentHostSyntheticListener("@myAnim.done", function MyAnimDir_animation_myAnim_done_HostBindingHandler($event) { return ctx.onDone(); });
352352
} if (rf & 2) {
353-
$r3$.ɵɵcomponentHostSyntheticProperty(elIndex, "@myAnim", $r3$.ɵɵbind(ctx.myAnimState), null, true);
353+
$r3$.ɵɵupdateSyntheticHostBinding("@myAnim", ctx.myAnimState, null, true);
354354
}
355355
}
356356

packages/compiler/src/render3/r3_identifiers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export class Identifiers {
3333

3434
static select: o.ExternalReference = {name: 'ɵɵselect', moduleName: CORE};
3535

36-
static componentHostSyntheticProperty:
37-
o.ExternalReference = {name: 'ɵɵcomponentHostSyntheticProperty', moduleName: CORE};
36+
static updateSyntheticHostBinding:
37+
o.ExternalReference = {name: 'ɵɵupdateSyntheticHostBinding', moduleName: CORE};
3838

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

packages/compiler/src/render3/view/compiler.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -667,18 +667,7 @@ function createHostBindingsFunction(
667667
sanitizerFn = resolveSanitizationFn(securityContexts[0], isAttribute);
668668
}
669669
}
670-
const isInstructionWithoutElementIndex =
671-
instruction === R3.property || instruction === R3.attribute;
672-
const instructionParams: o.Expression[] = isInstructionWithoutElementIndex ?
673-
[
674-
o.literal(bindingName),
675-
bindingExpr.currValExpr,
676-
] :
677-
[
678-
elVarExp,
679-
o.literal(bindingName),
680-
o.importExpr(R3.bind).callFn([bindingExpr.currValExpr]),
681-
];
670+
const instructionParams = [o.literal(bindingName), bindingExpr.currValExpr];
682671
if (sanitizerFn) {
683672
instructionParams.push(sanitizerFn);
684673
}
@@ -783,7 +772,7 @@ function getBindingNameAndInstruction(binding: ParsedProperty):
783772
// host bindings that have a synthetic property (e.g. @foo) should always be rendered
784773
// in the context of the component and not the parent. Therefore there is a special
785774
// compatibility instruction available for this purpose.
786-
instruction = R3.componentHostSyntheticProperty;
775+
instruction = R3.updateSyntheticHostBinding;
787776
} else {
788777
instruction = R3.property;
789778
}

packages/core/src/core_render3_private_export.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export {
120120
ɵɵpropertyInterpolate7,
121121
ɵɵpropertyInterpolate8,
122122
ɵɵpropertyInterpolateV,
123-
ɵɵcomponentHostSyntheticProperty,
123+
ɵɵupdateSyntheticHostBinding,
124124
ɵɵcomponentHostSyntheticListener,
125125
ɵɵprojectionDef,
126126
ɵɵreference,

packages/core/src/render3/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export {
3939
ɵɵclassMap,
4040
ɵɵclassProp,
4141
ɵɵcomponentHostSyntheticListener,
42-
ɵɵcomponentHostSyntheticProperty,
4342

4443
ɵɵcontainer,
4544
ɵɵcontainerRefreshEnd,
@@ -119,6 +118,8 @@ export {
119118
ɵɵtextInterpolate7,
120119
ɵɵtextInterpolate8,
121120
ɵɵtextInterpolateV,
121+
122+
ɵɵupdateSyntheticHostBinding,
122123
} from './instructions/all';
123124
export {RenderFlags} from './interfaces/definition';
124125
export {CssSelectorList, ProjectionSlots} from './interfaces/projection';

packages/core/src/render3/instructions/property.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,12 @@ export function ɵɵelementProperty<T>(
110110
*
111111
* @codeGenApi
112112
*/
113-
export function ɵɵcomponentHostSyntheticProperty<T>(
114-
index: number, propName: string, value: T | NO_CHANGE, sanitizer?: SanitizerFn | null,
115-
nativeOnly?: boolean) {
116-
if (value !== NO_CHANGE) {
117-
elementPropertyInternal(index, propName, value, sanitizer, nativeOnly, loadComponentRenderer);
113+
export function ɵɵupdateSyntheticHostBinding<T>(
114+
propName: string, value: T | NO_CHANGE, sanitizer?: SanitizerFn | null, nativeOnly?: boolean) {
115+
const index = getSelectedIndex();
116+
// TODO(benlesh): remove bind call here.
117+
const bound = ɵɵbind(value);
118+
if (bound !== NO_CHANGE) {
119+
elementPropertyInternal(index, propName, bound, sanitizer, nativeOnly, loadComponentRenderer);
118120
}
119121
}

packages/core/src/render3/jit/environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export const angularCoreEnv: {[name: string]: Function} =
8888
'ɵɵload': r3.ɵɵload,
8989
'ɵɵprojection': r3.ɵɵprojection,
9090
'ɵɵelementProperty': r3.ɵɵelementProperty,
91-
'ɵɵcomponentHostSyntheticProperty': r3.ɵɵcomponentHostSyntheticProperty,
91+
'ɵɵupdateSyntheticHostBinding': r3.ɵɵupdateSyntheticHostBinding,
9292
'ɵɵcomponentHostSyntheticListener': r3.ɵɵcomponentHostSyntheticListener,
9393
'ɵɵpipeBind1': r3.ɵɵpipeBind1,
9494
'ɵɵpipeBind2': r3.ɵɵpipeBind2,

tools/public_api_guard/core/core.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,6 @@ export declare type ɵɵComponentDefWithMeta<T, Selector extends String, ExportA
712712

713713
export declare function ɵɵcomponentHostSyntheticListener<T>(eventName: string, listenerFn: (e?: any) => any, useCapture?: boolean, eventTargetResolver?: GlobalTargetResolver): void;
714714

715-
export declare function ɵɵcomponentHostSyntheticProperty<T>(index: number, propName: string, value: T | NO_CHANGE, sanitizer?: SanitizerFn | null, nativeOnly?: boolean): void;
716-
717715
export declare function ɵɵcontainer(index: number): void;
718716

719717
export declare function ɵɵcontainerRefreshEnd(): void;
@@ -1077,6 +1075,8 @@ export declare function ɵɵtextInterpolate8(prefix: string, v0: any, i0: string
10771075

10781076
export declare function ɵɵtextInterpolateV(values: any[]): TsickleIssue1009;
10791077

1078+
export declare function ɵɵupdateSyntheticHostBinding<T>(propName: string, value: T | NO_CHANGE, sanitizer?: SanitizerFn | null, nativeOnly?: boolean): void;
1079+
10801080
export declare function ɵɵviewQuery<T>(predicate: Type<any> | string[], descend: boolean, read: any): QueryList<T>;
10811081

10821082
export declare const PACKAGE_ROOT_URL: InjectionToken<string>;

0 commit comments

Comments
 (0)