Skip to content

When elAttribute=class, it should check if the previousValue is undefined #191

@kadishmal

Description

@kadishmal

Basically this line https://github.com/theironcook/Backbone.ModelBinder/blob/master/Backbone.ModelBinder.js#L400 is not completely correct:

if(!_.isUndefined(previousValue) || !_.isUndefined(currentValue)){
    previousValue = this._getConvertedValue(Backbone.ModelBinder.Constants.ModelToView, elementBinding, previousValue);
    el.removeClass(previousValue);
}

It should be:

previousValue && el.removeClass(previousValue);

That is it should check whether the previousValue is not undefined. If it is, then el.removeClass(undefined) will remove all the classes previously defined for some other purposes. Imagine I have an icon defined as <i class="fa fa-envelope"/>. If previousValue=undefined, then it will remove fa fa-envelope classes completely so the element will end up being <i class=""/>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions