fix(compiler): generate core-compliant hostBindings property (#24087)

This makes `hostBindings` code, generated by compiler and used in core package, identical.

Fix #24013

PR Close #24087
This commit is contained in:
alexzuza 2018-05-24 01:07:09 +04:00 committed by Matias Niemelä
parent 186118e684
commit 01b5acd7cf
3 changed files with 6 additions and 5 deletions

View File

@ -65,6 +65,7 @@ export class Identifiers {
static pipeBindV: o.ExternalReference = {name: 'ɵpbV', moduleName: CORE};
static load: o.ExternalReference = {name: 'ɵld', moduleName: CORE};
static loadDirective: o.ExternalReference = {name: 'ɵd', moduleName: CORE};
static pipe: o.ExternalReference = {name: 'ɵPp', moduleName: CORE};

View File

@ -359,8 +359,8 @@ function createHostBindingsFunction(
for (let index = 0; index < meta.queries.length; index++) {
const query = meta.queries[index];
// e.g. r3.qR(tmp = r3.ld(dirIndex)[1]) && (r3.ld(dirIndex)[0].someDir = tmp);
const getDirectiveMemory = o.importExpr(R3.load).callFn([o.variable('dirIndex')]);
// e.g. r3.qR(tmp = r3.d(dirIndex)[1]) && (r3.d(dirIndex)[0].someDir = tmp);
const getDirectiveMemory = o.importExpr(R3.loadDirective).callFn([o.variable('dirIndex')]);
// The query list is at the query index + 1 because the directive itself is in slot 0.
const getQueryList = getDirectiveMemory.key(o.literal(index + 1));
const assignToTemporary = temporary().set(getQueryList);
@ -376,7 +376,7 @@ function createHostBindingsFunction(
// Calculate the host property bindings
const bindings = bindingParser.createBoundHostProperties(directiveSummary, hostBindingSourceSpan);
const bindingContext = o.importExpr(R3.load).callFn([o.variable('dirIndex')]);
const bindingContext = o.importExpr(R3.loadDirective).callFn([o.variable('dirIndex')]);
if (bindings) {
for (const binding of bindings) {
const bindingExpr = convertPropertyBinding(

View File

@ -291,7 +291,7 @@ describe('compiler compliance', () => {
factory: function HostBindingDir_Factory() { return new HostBindingDir(); },
hostBindings: function HostBindingDir_HostBindings(
dirIndex: $number$, elIndex: $number$) {
$r3$.ɵp(elIndex, 'id', $r3$.ɵb($r3$.ɵld(dirIndex).dirId));
$r3$.ɵp(elIndex, 'id', $r3$.ɵb($r3$.ɵd(dirIndex).dirId));
}
});
`;
@ -823,7 +823,7 @@ describe('compiler compliance', () => {
hostBindings: function ContentQueryComponent_HostBindings(
dirIndex: $number$, elIndex: $number$) {
var $tmp$: $any$;
($r3$.ɵqR(($tmp$ = $r3$.ɵld(dirIndex)[1])) && ($r3$.ɵld(dirIndex)[0].someDir = $tmp$.first));
($r3$.ɵqR(($tmp$ = $r3$.ɵd(dirIndex)[1])) && ($r3$.ɵd(dirIndex)[0].someDir = $tmp$.first));
},
template: function ContentQueryComponent_Template(
rf: $RenderFlags$, ctx: $ContentQueryComponent$) {