Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

ng-class does not change classes properly when there are duplicate class names #7929

Closed
alisabzevari opened this issue Jun 21, 2014 · 3 comments

Comments

@alisabzevari
Copy link

I have the following icon with fontawesome:

<i data-ng-class="{'fa-clock-o fa purple':suggestion.notificationStatus.id == 2, 'fa fa-circle-o orange2':suggestion.notificationStatus.id == 1}"></i>

When I change suggestion.notificationStatus.id, ng-class removes fa from classes that applied to element.
I saw the source code. In $AnimateProvider there is a method named setClass. The problem is it first adds classes then removes classes. The parameters that this method receive are as following:

  • element: i
  • add: "fa-clock-o fa purple"
  • remove: "fa fa-circle-o orange2"
  • done: undefined

I think a good solution is not to have any duplicate classes in setClass method because changing the order of remove and add in this method may raise other problems. So it can be fixed by fixing updateClasses function of ng-class directive.

Note that I am using angularjs v1.2.16

@matsko
Copy link
Contributor

matsko commented Jun 21, 2014

@btford would you mind looking into this one?

@btford
Copy link
Contributor

btford commented Jun 22, 2014

Sure

@btford
Copy link
Contributor

btford commented Jun 27, 2014

Duplicate of #5271. This should be fixed by c967792. The latest 1.2.x contains this fix.

@alisabzevari in the future, please:

  1. Provide a reproduction via plnkr.co or jsfiddle. Like this: http://plnkr.co/edit/F4Tur2gGOKc3FxFT0Guc?p=preview
  2. Check that the problem persists after updating Angular.

This saves us a lot of time. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants