diff --git a/packages/compiler-cli/test/compliance/r3_compiler_compliance_spec.ts b/packages/compiler-cli/test/compliance/r3_compiler_compliance_spec.ts index b67fa0b21c..6afa8627c8 100644 --- a/packages/compiler-cli/test/compliance/r3_compiler_compliance_spec.ts +++ b/packages/compiler-cli/test/compliance/r3_compiler_compliance_spec.ts @@ -3253,7 +3253,7 @@ describe('compiler compliance', () => { $r3$.ɵɵallocHostVars(1); } if (rf & 2) { - $r3$.ɵɵelementAttribute(elIndex, "tabindex", $r3$.ɵɵbind(ctx.tabindex)); + $r3$.ɵɵattribute("tabindex", ctx.tabindex); } } }); diff --git a/packages/compiler-cli/test/compliance/r3_view_compiler_binding_spec.ts b/packages/compiler-cli/test/compliance/r3_view_compiler_binding_spec.ts index 14a9ac0c86..0c0cf93db7 100644 --- a/packages/compiler-cli/test/compliance/r3_view_compiler_binding_spec.ts +++ b/packages/compiler-cli/test/compliance/r3_view_compiler_binding_spec.ts @@ -308,7 +308,7 @@ describe('compiler compliance: bindings', () => { $r3$.ɵɵallocHostVars(1); } if (rf & 2) { - $r3$.ɵɵelementAttribute(elIndex, "required", $r3$.ɵɵbind(ctx.required)); + $r3$.ɵɵattribute("required", ctx.required); } } }); @@ -514,26 +514,26 @@ describe('compiler compliance: bindings', () => { const template = ` … if (rf & 2) { - i0.Δselect(0); - i0.ΔattributeInterpolateV("title", ["a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h", ctx.eight, "i", ctx.nine, "j"]); - i0.Δselect(1); - i0.ΔattributeInterpolate8("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h", ctx.eight, "i"); - i0.Δselect(2); - i0.ΔattributeInterpolate7("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h"); - i0.Δselect(3); - i0.ΔattributeInterpolate6("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g"); - i0.Δselect(4); - i0.ΔattributeInterpolate5("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f"); - i0.Δselect(5); - i0.ΔattributeInterpolate4("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e"); - i0.Δselect(6); - i0.ΔattributeInterpolate3("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d"); - i0.Δselect(7); - i0.ΔattributeInterpolate2("title", "a", ctx.one, "b", ctx.two, "c"); - i0.Δselect(8); - i0.ΔattributeInterpolate1("title", "a", ctx.one, "b"); - i0.Δselect(9); - i0.ΔattributeInterpolate("title", ctx.one); + i0.ɵɵselect(0); + i0.ɵɵattributeInterpolateV("title", ["a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h", ctx.eight, "i", ctx.nine, "j"]); + i0.ɵɵselect(1); + i0.ɵɵattributeInterpolate8("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h", ctx.eight, "i"); + i0.ɵɵselect(2); + i0.ɵɵattributeInterpolate7("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g", ctx.seven, "h"); + i0.ɵɵselect(3); + i0.ɵɵattributeInterpolate6("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f", ctx.six, "g"); + i0.ɵɵselect(4); + i0.ɵɵattributeInterpolate5("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e", ctx.five, "f"); + i0.ɵɵselect(5); + i0.ɵɵattributeInterpolate4("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d", ctx.four, "e"); + i0.ɵɵselect(6); + i0.ɵɵattributeInterpolate3("title", "a", ctx.one, "b", ctx.two, "c", ctx.three, "d"); + i0.ɵɵselect(7); + i0.ɵɵattributeInterpolate2("title", "a", ctx.one, "b", ctx.two, "c"); + i0.ɵɵselect(8); + i0.ɵɵattributeInterpolate1("title", "a", ctx.one, "b"); + i0.ɵɵselect(9); + i0.ɵɵattributeInterpolate("title", ctx.one); } … `; diff --git a/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts b/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts index 4150691c0e..5c818815df 100644 --- a/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts +++ b/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts @@ -1769,7 +1769,7 @@ describe('ngtsc behavioral tests', () => { i0.ɵɵstyling(_c0); } if (rf & 2) { - i0.ɵɵelementAttribute(elIndex, "hello", i0.ɵɵbind(ctx.foo)); + i0.ɵɵattribute("hello", ctx.foo); i0.ɵɵproperty("prop", ctx.bar, null, true); i0.ɵɵclassProp(0, ctx.someClass); i0.ɵɵstylingApply(); @@ -1826,7 +1826,7 @@ describe('ngtsc behavioral tests', () => { `); env.driveMain(); - expect(env.getContents('test.js')).toContain('"hello", i0.ɵɵbind(ctx.foo)'); + expect(env.getContents('test.js')).toContain('i0.ɵɵattribute("hello", ctx.foo)'); }); it('should generate host listeners for directives within hostBindings section', () => { @@ -3216,12 +3216,12 @@ describe('ngtsc behavioral tests', () => { i0.ɵɵallocHostVars(6); } if (rf & 2) { - i0.ɵɵelementAttribute(elIndex, "href", i0.ɵɵbind(ctx.attrHref), i0.ɵɵsanitizeUrlOrResourceUrl); - i0.ɵɵelementAttribute(elIndex, "src", i0.ɵɵbind(ctx.attrSrc), i0.ɵɵsanitizeUrlOrResourceUrl); - i0.ɵɵelementAttribute(elIndex, "action", i0.ɵɵbind(ctx.attrAction), i0.ɵɵsanitizeUrl); - i0.ɵɵelementAttribute(elIndex, "profile", i0.ɵɵbind(ctx.attrProfile), i0.ɵɵsanitizeResourceUrl); - i0.ɵɵelementAttribute(elIndex, "innerHTML", i0.ɵɵbind(ctx.attrInnerHTML), i0.ɵɵsanitizeHtml); - i0.ɵɵelementAttribute(elIndex, "title", i0.ɵɵbind(ctx.attrSafeTitle)); + i0.ɵɵattribute("href", ctx.attrHref, i0.ɵɵsanitizeUrlOrResourceUrl); + i0.ɵɵattribute("src", ctx.attrSrc, i0.ɵɵsanitizeUrlOrResourceUrl); + i0.ɵɵattribute("action", ctx.attrAction, i0.ɵɵsanitizeUrl); + i0.ɵɵattribute("profile", ctx.attrProfile, i0.ɵɵsanitizeResourceUrl); + i0.ɵɵattribute("innerHTML", ctx.attrInnerHTML, i0.ɵɵsanitizeHtml); + i0.ɵɵattribute("title", ctx.attrSafeTitle); } } `; @@ -3314,9 +3314,9 @@ describe('ngtsc behavioral tests', () => { i0.ɵɵproperty("src", ctx.srcProp, null, true); i0.ɵɵproperty("href", ctx.hrefProp, null, true); i0.ɵɵproperty("title", ctx.titleProp, null, true); - i0.ɵɵelementAttribute(elIndex, "src", i0.ɵɵbind(ctx.srcAttr)); - i0.ɵɵelementAttribute(elIndex, "href", i0.ɵɵbind(ctx.hrefAttr)); - i0.ɵɵelementAttribute(elIndex, "title", i0.ɵɵbind(ctx.titleAttr)); + i0.ɵɵattribute("src", ctx.srcAttr); + i0.ɵɵattribute("href", ctx.hrefAttr); + i0.ɵɵattribute("title", ctx.titleAttr); } } `; diff --git a/packages/compiler/src/render3/view/compiler.ts b/packages/compiler/src/render3/view/compiler.ts index 7ea88f0221..175bee4458 100644 --- a/packages/compiler/src/render3/view/compiler.ts +++ b/packages/compiler/src/render3/view/compiler.ts @@ -667,9 +667,9 @@ function createHostBindingsFunction( sanitizerFn = resolveSanitizationFn(securityContexts[0], isAttribute); } } - - const isPropertyInstruction = instruction === R3.property; - const instructionParams: o.Expression[] = isPropertyInstruction ? + const isInstructionWithoutElementIndex = + instruction === R3.property || instruction === R3.attribute; + const instructionParams: o.Expression[] = isInstructionWithoutElementIndex ? [ o.literal(bindingName), bindingExpr.currValExpr, @@ -776,7 +776,7 @@ function getBindingNameAndInstruction(binding: ParsedProperty): const attrMatches = bindingName.match(ATTR_REGEX); if (attrMatches) { bindingName = attrMatches[1]; - instruction = R3.elementAttribute; + instruction = R3.attribute; } else { if (binding.isAnimation) { bindingName = prepareSyntheticPropertyName(bindingName);