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.

When interpolated class attribute changes, classes from ng-class are not merged in #1016

Closed
@maxmart

Description

@maxmart

Open http://jsfiddle.net/ADukg/224/
Set ngclass to true by clicking the first button. Note how the ngclass text turns green.
Then set class to true by clicking the second button. Note how the ngclass text turned red again.

So:
Result: div element has class="static class", thus coloring "class" green and "ngclass" red
Expected result: div element has class="static class ngclass", thus coloring both "class" and "ngclass" green

I have a (maybe very ugly) fix for this, which involves:

  1. Not setting attr[name] to undefined when name === 'class' in addAttrInterpolateDirective()
  2. $watch:ing $interpolate(attr['class']) in classDirective() and reapplying the "ngclasses" when it changes.

The reason I'm not totally sure about this solution is that I don't know why you're setting attributes to undefined in addAttrInterpolateDirective(), and I'm not sure what consequences it will have if we don't.

What do you think about this?

I can post some more code later, but I want to see if all tests pass first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions