ngStyle not removing values #16860
Description
I'm submitting a ...
- regression from 1.6.x to 1.7.8
- security issue
- issue caused by a new browser version
- other
Current behavior:
In AngularJS 1.6 (and even in 1.7.0) the ngStyle directive was able to add/remove single properties when the expression for the single property was evaluated as false.
For example:
ng-style="{'float': isRight && 'right' }"
was dynamically adding/removing the 'float: right' style when the isRight scope expression changed.
In Angular 1.7.8 this only happens when isRight switches from false to true. Switching back to false will leave the 'float: right' style set.
As a workaround, this expression instead works in both 1.6.x and 1.7.8:
ng-style="isRight && {'float': 'right' }"
Expected / new behavior:
Expressions like
ng-style="{'float': isRight && 'right' }"
should be still supported for backward compatibility. Or at least the change (if intentional) should be documented in the changelog documentation.
Regards
Minimal reproduction of the problem with instructions:
Here a plunkr to replicate the issue:
https://plnkr.co/edit/FsWbrVvfAYvuJCoGszi2?p=preview
AngularJS version: 1.7.8
Browser: [all]