Add a test case for cloning the attribute object

The problem is that the attribute object isn't cloned so when an ID is
set through the constructor attributes[id] will get set on all
subsequent objects as well.
This commit is contained in:
Nicklas Ansman Giertz
2012-04-02 12:37:25 +02:00
parent fd4df5a810
commit d852c729df

View File

@@ -214,4 +214,11 @@ $(document).ready(function() {
b.trigger('click');
});
test("Clone attributes object", function() {
var View = Backbone.View.extend({attributes: {foo: 'bar'}});
var v1 = new View({id: 'foo'});
ok(v1.el.id === 'foo');
var v2 = new View();
ok(!v2.el.id);
});
});