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

ngClass is too greedy #4960

Closed
Closed
@matsko

Description

@matsko

ngClass and {{ class }} are too greedy when dealing with class value changes.

For example:

<div ng-click="disableOne()" ng-class="{one:one, two:two, three:three}"></div>

If you set:

//addClass('one two three')
$scope.one = true;
$scope.two = true;
$scope.three = true;

$scope.disableOne = function() {
  //removeClass('one two three')
  //addClass('two three')
  $scope.one = false;
}

Then what will happen is it will remove all the classes first and then add back .two + .three.

This causes an issue with animations because if you have a transition on one of the classes (say .two) then the removeClass animation will be skipped since addClass happens right after cancelling out the removeClass animation, but this shouldn't happen in the first place since there should not be an addClass operation at all if only one ngClass value is set to false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions