escape method cache issue #8

Closed
mimopo opened this Issue Nov 2, 2012 · 1 comment

Comments

Projects
None yet
2 participants
@mimopo

mimopo commented Nov 2, 2012

If you try to use "escape" method with mutators it will be cached, this is a problem since mutators are dynamic.

Example:

window.Example = Backbone.Model.extend({
    defaults:{
        a: 1,
        b: 1
    },
    mutators:{
        c: function(){
            return this.a + this.b;
        }
    }
});
var E = new Example();
alert(E.escape("c")); // displays 2
E.set("a", 2);
alert(E.escape("c")); // displays 2, must be 3

Possible fix:

// override get functionality to get HTML-escaped the mutator props
    Mutator.prototype.escape = function (attr){
        var val = this.get(attr);
        return _.escape(val == null ? '' : '' + val);
    };

@ghost ghost assigned asciidisco Dec 13, 2012

@asciidisco

This comment has been minimized.

Show comment
Hide comment
@asciidisco

asciidisco Apr 30, 2013

Owner

Implemented & tested, will be in the next release.

Owner

asciidisco commented Apr 30, 2013

Implemented & tested, will be in the next release.

@asciidisco asciidisco closed this Apr 30, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment