Object with same key duplicated, not updated. #44

Closed
peterp opened this Issue Jul 20, 2011 · 1 comment

1 participant

@peterp
new Lawnchair(function() {

    this.save({key: 'pew', attr1: 'value1'});
    this.save({key: 'pew', attr1: 'value1'});
    this.save({key: 'pew', attr1: 'value1'});

    this.all(function(o) {
        console.log(o); // Object , Object, Object
    });
});

Oddly enough, if I allow Lawnchair to save and determine its own key the duplication doesn't occur:

new Lawnchair(function() {

this.save({dummy: 'object');
this.save({key: 'pew', attr1: 'value1'});
this.save({key: 'pew', attr1: 'value1'});

this.all(function(o) {
    console.log(o); // Object , Object
});

});

@peterp
// https://github.com/brianleroux/lawnchair/blob/master/src/adapters/dom.js#L49
for (var i = 0, l = a.length; i < l; i++) {
   if (key === a[i]) return i // i == 0
}

Perhaps save should explicitly check for === false?

@peterp peterp closed this Jul 20, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment