Skip to content

Angular animations: the style() function doesn't change property unless it's in camel case #48246

Closed

Description

@blablaalb

Which @angular/* package(s) are the source of the bug?

animations

Is this a regression?

No

Description

In some circumstances Angular Animations doesn't apply style if the css property is declared inside quotation marks such as 'background-color': 'red'. Here's the post on stackoverflow describing the issue.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/angular-ivy-vhkked?file=src%2Fapp%2Fapp.component.ts

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

@angular/cli: 1.0.0
node: 19.1.0
os: win32 x64
@angular/animations: 4.4.7
@angular/common: 4.4.7
@angular/compiler: 4.4.7
@angular/compiler-cli: 4.4.7
@angular/core: 4.4.7
@angular/forms: 4.4.7
@angular/http: 4.4.7
@angular/platform-browser: 4.4.7
@angular/platform-browser-dynamic: 4.4.7
@angular/platform-server: 4.4.7
@angular/router: 4.4.7
@angular/cli: 1.0.0

Anything else?

No response

Activity

  1. added
    area: animations
    on Nov 28, 2022
  2. added this to the needsTriage milestone on Nov 28, 2022
  3. jessicajaniuk commented on Dec 9, 2022

    @jessicajaniuk
    Contributor

    This is actually working as intended. There's more information on this in our documentation. Essentially this is because the style() definitions rely on the javascript naming for properties, which uses camel case, rather than native CSS definitions. style() definitions are applied on the javascript side. So they need that structure.

  4. blablaalb commented on Dec 9, 2022

    @blablaalb
    Author

    This is actually working as intended. There's more information on this in our documentation. Essentially this is because the style() definitions rely on the javascript naming for properties, which uses camel case, rather than native CSS definitions. style() definitions are applied on the javascript side. So they need that structure.

    The documentation says it's either can be done with camel case notation or with native css property names wrapped inside quotes.

    Use the style() function to define a set of styles to associate with a given state name. You must use camelCase for style attributes that contain dashes, such as backgroundColor or wrap them in quotes, such as 'background-color'.

  5. dario-piotrowicz commented on Dec 10, 2022

    @dario-piotrowicz
    Contributor

    @jessicajaniuk although under the hood the properties are converted to camelCase, the api does allow the use of standard kabab-case property names, so I do think that @blablaalb is right here.

    Moreover I think I might likely have introduced the bug myself by accident back in #42763, sorry for the inconvenience 😓

    I''ve created a PR with the fix, and I've also added a unit test so that won't risk regressing this again.

    Thanks a bunch @blablaalb for raising the issue! 🙂

  6. added a commit that references this issue on Dec 10, 2022
    03fe696
  7. added a commit that references this issue on Dec 12, 2022
    6c1064c
  8. angular-automatic-lock-bot commented on Jan 12, 2023

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  9. locked and limited conversation to collaborators on Jan 12, 2023
  10. added a commit that references this issue on Feb 1, 2023
    4fd8fe2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: animations

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions