mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
removing obsolete error case.
This commit is contained in:
@@ -173,9 +173,7 @@
|
||||
this.attributes = {};
|
||||
this._escapedAttributes = {};
|
||||
this.cid = _.uniqueId('c');
|
||||
if (!this.set(attributes, {silent: true})) {
|
||||
throw new Error("Can't create an invalid model");
|
||||
}
|
||||
this.set(attributes, {silent: true});
|
||||
delete this._changed;
|
||||
this._previousAttributes = _.clone(this.attributes);
|
||||
this.initialize.apply(this, arguments);
|
||||
|
||||
@@ -59,34 +59,6 @@ $(document).ready(function() {
|
||||
equal(col.get(101), model);
|
||||
});
|
||||
|
||||
test("Collection: add model with attributes modified by set", function() {
|
||||
var CustomSetModel = Backbone.Model.extend({
|
||||
defaults: {
|
||||
number_as_string: null //presence of defaults forces extend
|
||||
},
|
||||
|
||||
validate: function (attributes) {
|
||||
if (!_.isString(attributes.num_as_string)) {
|
||||
return 'fail';
|
||||
}
|
||||
},
|
||||
|
||||
set: function (attributes, options) {
|
||||
if (attributes.num_as_string) {
|
||||
attributes.num_as_string = attributes.num_as_string.toString();
|
||||
}
|
||||
Backbone.Model.prototype.set.call(this, attributes, options);
|
||||
}
|
||||
});
|
||||
|
||||
var CustomSetCollection = Backbone.Collection.extend({
|
||||
model: CustomSetModel
|
||||
});
|
||||
raises(function(){
|
||||
new CustomSetCollection([{ num_as_string: 2 }]);
|
||||
});
|
||||
});
|
||||
|
||||
test("Collection: update index when id changes", function() {
|
||||
var col = new Backbone.Collection();
|
||||
col.add([
|
||||
|
||||
Reference in New Issue
Block a user