diff --git a/packages/core/src/render3/styling/class_and_style_bindings.ts b/packages/core/src/render3/styling/class_and_style_bindings.ts index 0bcee71d94..a22b096772 100644 --- a/packages/core/src/render3/styling/class_and_style_bindings.ts +++ b/packages/core/src/render3/styling/class_and_style_bindings.ts @@ -951,12 +951,12 @@ export function setStyle( ngDevMode && ngDevMode.rendererSetStyle++; isProceduralRenderer(renderer) ? renderer.setStyle(native, prop, value, RendererStyleFlags3.DashCase) : - native['style'].setProperty(prop, value); + native.style[prop] = value; } else { ngDevMode && ngDevMode.rendererRemoveStyle++; isProceduralRenderer(renderer) ? renderer.removeStyle(native, prop, RendererStyleFlags3.DashCase) : - native['style'].removeProperty(prop); + native.style[prop] = ''; } } diff --git a/packages/core/test/render3/styling/class_and_style_bindings_spec.ts b/packages/core/test/render3/styling/class_and_style_bindings_spec.ts index 05f4fc0a85..690e104c87 100644 --- a/packages/core/test/render3/styling/class_and_style_bindings_spec.ts +++ b/packages/core/test/render3/styling/class_and_style_bindings_spec.ts @@ -380,6 +380,41 @@ describe('style and class based bindings', () => { .toEqual( ''); }); + + it('should support binding to camelCased style properties', () => { + //
+ class Comp { + borderWidth: string = '3px'; + + static ngComponentDef = defineComponent({ + type: Comp, + selectors: [['comp']], + factory: () => new Comp(), + consts: 1, + vars: 0, + template: (rf: RenderFlags, ctx: Comp) => { + if (rf & RenderFlags.Create) { + elementStart(0, 'div'); + elementStyling(null, ['borderWidth']); + elementEnd(); + } + if (rf & RenderFlags.Update) { + elementStyleProp(0, 0, ctx.borderWidth); + elementStylingApply(0); + } + } + }); + } + + const fixture = new ComponentFixture(Comp); + fixture.update(); + + const target = fixture.hostElement.querySelector('div') !as any; + + expect(target.style.borderWidth).toEqual('3px'); + expect(fixture.html).toEqual('
'); + }); + }); describe('dynamic styling properties within a styling context', () => {