Update vendors.

Former-commit-id: 76887b14d32e661f4c415393637478d93174329d
This commit is contained in:
John-David Dalton
2012-10-31 00:38:38 -07:00
parent 1baefebe8f
commit 581d73afe0
3 changed files with 34 additions and 18 deletions

View File

@@ -261,15 +261,16 @@
// Set a hash of model attributes on the object, firing `"change"` unless
// you choose to silence it.
set: function(attrs, options) {
var attr, key, val;
if (attrs == null) return this;
set: function(key, val, options) {
var attr, attrs;
if (key == null) return this;
// Handle both `"key", value` and `{key: value}` -style arguments.
if (!_.isObject(attrs)) {
key = attrs;
(attrs = {})[key] = options;
options = arguments[2];
if (_.isObject(key)) {
attrs = key;
options = val;
} else {
(attrs = {})[key] = val;
}
// Extract attributes and options.
@@ -352,14 +353,15 @@
// Set a hash of model attributes, and sync the model to the server.
// If the server returns an attributes hash that differs, the model's
// state will be `set` again.
save: function(attrs, options) {
var key, current, done;
save: function(key, val, options) {
var attrs, current, done;
// Handle both `"key", value` and `{key: value}` -style arguments.
if (attrs != null && !_.isObject(attrs)) {
key = attrs;
(attrs = {})[key] = options;
options = arguments[2];
if (key == null || _.isObject(key)) {
attrs = key;
options = val;
} else if (key != null) {
(attrs = {})[key] = val;
}
options = options ? _.clone(options) : {};
@@ -948,8 +950,7 @@
if (!this.routes) return;
var route, routes = _.keys(this.routes);
while ((route = routes.pop()) != null) {
var name = this.routes[route];
this.route(route, name, this[name]);
this.route(route, this.routes[route]);
}
},

View File

@@ -701,4 +701,19 @@ $(document).ready(function() {
collection.add([{id: 1, x: 1}, {id: 2, x: 2}]);
deepEqual(added, [1, 2]);
});
test("fetch parses models by default", 1, function() {
var model = {};
var Collection = Backbone.Collection.extend({
url: 'test',
model: Backbone.Model.extend({
parse: function(resp) {
strictEqual(resp, model);
}
})
});
new Collection().fetch();
this.ajaxSettings.success([model]);
});
});

View File

@@ -4,8 +4,8 @@
**JSON 3** is a modern JSON implementation compatible with a variety of JavaScript platforms, including Internet Explorer 6, Opera 7, Safari 2, and Netscape 6. The current version is **3.2.4**.
- [Development Version](http://bestiejs.github.com/json3/lib/json3.js) *(36.5 KB; uncompressed with comments)*
- [Production Version](http://bestiejs.github.com/json3/lib/json3.min.js) *(3.0 KB; compressed and `gzip`-ped)*
- [Development Version](http://cdnjs.cloudflare.com/ajax/libs/json3/3.2.4/json3.js) *(36.5 KB; uncompressed with comments)*
- [Production Version](http://cdnjs.cloudflare.com/ajax/libs/json3/3.2.4/json3.min.js) *(3.0 KB; compressed and `gzip`-ped)*
[JSON](http://json.org/) is a language-independent data interchange format based on a loose subset of the JavaScript grammar. Originally popularized by [Douglas Crockford](http://www.crockford.com/), the format was standardized in the [fifth edition](http://es5.github.com/) of the ECMAScript specification. The 5.1 edition, ratified in June 2011, incorporates several modifications to the grammar pertaining to the serialization of dates.
@@ -42,7 +42,7 @@ Portions of the date serialization code are adapted from the [`date-shim`](https
## Web Browsers
<script src="http://bestiejs.github.com/json3/lib/json3.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/json3/3.2.4/json3.min.js"></script>
<script>
JSON.stringify({"Hello": 123});
// => '{"Hello":123}'