Skip to content

Commit

Permalink
refactor(ivy): add ɵɵupdateSyntheticHostBinding command
Browse files Browse the repository at this point in the history
- Refactors `ɵɵcomponentHostSyntheticProperty` into `ɵɵupdateSyntheticHostBinding`, to better align it with other new instructions.
  • Loading branch information
benlesh committed May 30, 2019
1 parent 24ca8ba commit 1d76571
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -444,19 +444,17 @@ describe('compiler compliance', () => {
$r3$.ɵɵallocHostVars(14);
}
if (rf & 2) {
$r3$.ɵɵcomponentHostSyntheticProperty(elIndex, "@expansionHeight",
$r3$.ɵɵbind(
$r3$.ɵɵupdateSyntheticHostBinding("@expansionHeight",
$r3$.ɵɵpureFunction2(5, $_c1$, ctx.getExpandedState(),
$r3$.ɵɵpureFunction2(2, $_c0$, ctx.collapsedHeight, ctx.expandedHeight)
)
), null, true
, null, true
);
$r3$.ɵɵcomponentHostSyntheticProperty(elIndex, "@expansionWidth",
$r3$.ɵɵbind(
$r3$.ɵɵupdateSyntheticHostBinding("@expansionWidth",
$r3$.ɵɵpureFunction2(11, $_c1$, ctx.getExpandedState(),
$r3$.ɵɵpureFunction2(8, $_c2$, ctx.collapsedWidth, ctx.expandedWidth)
)
), null, true
, null, true
);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ describe('compiler compliance: styling', () => {
$r3$.ɵɵcomponentHostSyntheticListener("@myAnim.start", function MyAnimDir_animation_myAnim_start_HostBindingHandler($event) { return ctx.onStart(); });
$r3$.ɵɵcomponentHostSyntheticListener("@myAnim.done", function MyAnimDir_animation_myAnim_done_HostBindingHandler($event) { return ctx.onDone(); });
} if (rf & 2) {
$r3$.ɵɵcomponentHostSyntheticProperty(elIndex, "@myAnim", $r3$.ɵɵbind(ctx.myAnimState), null, true);
$r3$.ɵɵupdateSyntheticHostBinding("@myAnim", ctx.myAnimState, null, true);
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/compiler/src/render3/r3_identifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export class Identifiers {

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

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

static componentHostSyntheticListener:
o.ExternalReference = {name: 'ɵɵcomponentHostSyntheticListener', moduleName: CORE};
Expand Down
15 changes: 2 additions & 13 deletions packages/compiler/src/render3/view/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,18 +667,7 @@ function createHostBindingsFunction(
sanitizerFn = resolveSanitizationFn(securityContexts[0], isAttribute);
}
}
const isInstructionWithoutElementIndex =
instruction === R3.property || instruction === R3.attribute;
const instructionParams: o.Expression[] = isInstructionWithoutElementIndex ?
[
o.literal(bindingName),
bindingExpr.currValExpr,
] :
[
elVarExp,
o.literal(bindingName),
o.importExpr(R3.bind).callFn([bindingExpr.currValExpr]),
];
const instructionParams = [o.literal(bindingName), bindingExpr.currValExpr];
if (sanitizerFn) {
instructionParams.push(sanitizerFn);
}
Expand Down Expand Up @@ -783,7 +772,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.componentHostSyntheticProperty;
instruction = R3.updateSyntheticHostBinding;
} else {
instruction = R3.property;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/core_render3_private_export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export {
ɵɵpropertyInterpolate7,
ɵɵpropertyInterpolate8,
ɵɵpropertyInterpolateV,
ɵɵcomponentHostSyntheticProperty,
ɵɵupdateSyntheticHostBinding,
ɵɵcomponentHostSyntheticListener,
ɵɵprojectionDef,
ɵɵreference,
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/render3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export {
ɵɵclassMap,
ɵɵclassProp,
ɵɵcomponentHostSyntheticListener,
ɵɵcomponentHostSyntheticProperty,

ɵɵcontainer,
ɵɵcontainerRefreshEnd,
Expand Down Expand Up @@ -119,6 +118,8 @@ export {
ɵɵtextInterpolate7,
ɵɵtextInterpolate8,
ɵɵtextInterpolateV,

ɵɵupdateSyntheticHostBinding,
} from './instructions/all';
export {RenderFlags} from './interfaces/definition';
export {CssSelectorList} from './interfaces/projection';
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/render3/instructions/property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ export function ɵɵelementProperty<T>(
*
* @codeGenApi
*/
export function ɵɵcomponentHostSyntheticProperty<T>(
index: number, propName: string, value: T | NO_CHANGE, sanitizer?: SanitizerFn | null,
nativeOnly?: boolean) {
export function ɵɵupdateSyntheticHostBinding<T>(
propName: string, value: T | NO_CHANGE, sanitizer?: SanitizerFn | null, nativeOnly?: boolean) {
if (value !== NO_CHANGE) {
const index = getSelectedIndex();
elementPropertyInternal(index, propName, value, sanitizer, nativeOnly, loadComponentRenderer);
}
}
2 changes: 1 addition & 1 deletion packages/core/src/render3/jit/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const angularCoreEnv: {[name: string]: Function} =
'ɵɵload': r3.ɵɵload,
'ɵɵprojection': r3.ɵɵprojection,
'ɵɵelementProperty': r3.ɵɵelementProperty,
'ɵɵcomponentHostSyntheticProperty': r3.ɵɵcomponentHostSyntheticProperty,
'ɵɵupdateSyntheticHostBinding': r3.ɵɵupdateSyntheticHostBinding,
'ɵɵcomponentHostSyntheticListener': r3.ɵɵcomponentHostSyntheticListener,
'ɵɵpipeBind1': r3.ɵɵpipeBind1,
'ɵɵpipeBind2': r3.ɵɵpipeBind2,
Expand Down
4 changes: 2 additions & 2 deletions tools/public_api_guard/core/core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,6 @@ export declare type ɵɵComponentDefWithMeta<T, Selector extends String, ExportA

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

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

export declare function ɵɵcontainer(index: number): void;

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

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

export declare function ɵɵupdateSyntheticHostBinding<T>(propName: string, value: T | NO_CHANGE, sanitizer?: SanitizerFn | null, nativeOnly?: boolean): void;

export declare function ɵɵviewQuery<T>(predicate: Type<any> | string[], descend: boolean, read: any): QueryList<T>;

export declare const PACKAGE_ROOT_URL: InjectionToken<string>;
Expand Down

0 comments on commit 1d76571

Please sign in to comment.