fix #871 - calling set with 'attributes' property

This commit is contained in:
Brad Dunbar
2012-01-18 12:45:09 -05:00
parent 910ca3c190
commit b05deb5fb5
2 changed files with 7 additions and 1 deletions

View File

@@ -220,7 +220,7 @@
// Extract attributes and options.
options || (options = {});
if (!attrs) return this;
if (attrs.attributes) attrs = attrs.attributes;
if (attrs instanceof Backbone.Model) attrs = attrs.attributes;
if (options.unset) for (var attr in attrs) attrs[attr] = void 0;
var now = this.attributes, escaped = this._escapedAttributes;

View File

@@ -531,4 +531,10 @@ $(document).ready(function() {
model.set({a: 'a', b: 'b', c: 'c'});
});
test("#871, set with attributes property", function() {
var model = new Backbone.Model();
model.set({attributes: true});
ok(model.has('attributes'));
});
});