diff --git a/packages/compiler/src/render3/r3_template_transform.ts b/packages/compiler/src/render3/r3_template_transform.ts index fa4bc709fe..c8fd92d270 100644 --- a/packages/compiler/src/render3/r3_template_transform.ts +++ b/packages/compiler/src/render3/r3_template_transform.ts @@ -242,11 +242,11 @@ class HtmlAstToIvyAst implements html.Visitor { literal.push(new t.TextAttribute( prop.name, prop.expression.source || '', prop.sourceSpan, undefined, i18n)); } else { - // we skip validation here, since we do this check at runtime due to the fact that we need - // to make sure a given prop is not an input of some Directive (thus should not be a subject - // of this check) and Directive matching happens at runtime + // Note that validation is skipped and property mapping is disabled + // due to the fact that we need to make sure a given prop is not an + // input of a directive and directive matching happens at runtime. const bep = this.bindingParser.createBoundElementProperty( - elementName, prop, /* skipValidation */ true); + elementName, prop, /* skipValidation */ true, /* mapPropertyName */ false); bound.push(t.BoundAttribute.fromBoundElementProperty(bep, i18n)); } }); diff --git a/packages/compiler/src/template_parser/binding_parser.ts b/packages/compiler/src/template_parser/binding_parser.ts index 71d786bb96..1940825967 100644 --- a/packages/compiler/src/template_parser/binding_parser.ts +++ b/packages/compiler/src/template_parser/binding_parser.ts @@ -240,8 +240,8 @@ export class BindingParser { } createBoundElementProperty( - elementSelector: string, boundProp: ParsedProperty, - skipValidation: boolean = false): BoundElementProperty { + elementSelector: string, boundProp: ParsedProperty, skipValidation: boolean = false, + mapPropertyName: boolean = true): BoundElementProperty { if (boundProp.isAnimation) { return new BoundElementProperty( boundProp.name, BindingType.Animation, SecurityContext.NONE, boundProp.expression, null, @@ -286,12 +286,13 @@ export class BindingParser { // If not a special case, use the full property name if (boundPropertyName === null) { - boundPropertyName = this._schemaRegistry.getMappedPropName(boundProp.name); + const mappedPropName = this._schemaRegistry.getMappedPropName(boundProp.name); + boundPropertyName = mapPropertyName ? mappedPropName : boundProp.name; securityContexts = calcPossibleSecurityContexts( - this._schemaRegistry, elementSelector, boundPropertyName, false); + this._schemaRegistry, elementSelector, mappedPropName, false); bindingType = BindingType.Property; if (!skipValidation) { - this._validatePropertyOrAttributeName(boundPropertyName, boundProp.sourceSpan, false); + this._validatePropertyOrAttributeName(mappedPropName, boundProp.sourceSpan, false); } } @@ -455,4 +456,4 @@ export function calcPossibleSecurityContexts( elementName => registry.securityContext(elementName, propName, isAttribute))); }); return ctxs.length === 0 ? [SecurityContext.NONE] : Array.from(new Set(ctxs)).sort(); -} \ No newline at end of file +} diff --git a/packages/compiler/test/render3/r3_template_transform_spec.ts b/packages/compiler/test/render3/r3_template_transform_spec.ts index 5e8a541b2a..d41d598517 100644 --- a/packages/compiler/test/render3/r3_template_transform_spec.ts +++ b/packages/compiler/test/render3/r3_template_transform_spec.ts @@ -176,10 +176,10 @@ describe('R3 template transform', () => { ]); }); - it('should normalize property names via the element schema', () => { + it('should not normalize property names via the element schema', () => { expectFromHtml('
').toEqual([ ['Element', 'div'], - ['BoundAttribute', BindingType.Property, 'mappedProp', 'v'], + ['BoundAttribute', BindingType.Property, 'mappedAttr', 'v'], ]); }); @@ -499,4 +499,4 @@ describe('R3 template transform', () => { ]); }); }); -}); \ No newline at end of file +}); diff --git a/packages/core/src/render3/instructions.ts b/packages/core/src/render3/instructions.ts index 2c8b009b06..40fd1912bd 100644 --- a/packages/core/src/render3/instructions.ts +++ b/packages/core/src/render3/instructions.ts @@ -1213,6 +1213,18 @@ export function componentHostSyntheticProperty