mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Sync _.isFinite changes with Underscore and update vendor/underscore and vendor/backbone.
Former-commit-id: 9acb93a276a11da8186da76bd82f1fd6f89c27dd
This commit is contained in:
32
vendor/backbone/backbone.js
vendored
32
vendor/backbone/backbone.js
vendored
@@ -10,7 +10,7 @@
|
||||
// Initial Setup
|
||||
// -------------
|
||||
|
||||
// Save a reference to the global object (`window` in the browser, `global`
|
||||
// Save a reference to the global object (`window` in the browser, `exports`
|
||||
// on the server).
|
||||
var root = this;
|
||||
|
||||
@@ -185,7 +185,7 @@
|
||||
var defaults;
|
||||
var attrs = attributes || {};
|
||||
if (options && options.collection) this.collection = options.collection;
|
||||
if (options && options.parse) attributes = this.parse(attributes);
|
||||
if (options && options.parse) attrs = this.parse(attrs);
|
||||
if (defaults = _.result(this, 'defaults')) {
|
||||
attrs = _.extend({}, defaults, attrs);
|
||||
}
|
||||
@@ -946,12 +946,10 @@
|
||||
// routes can be defined at the bottom of the route map.
|
||||
_bindRoutes: function() {
|
||||
if (!this.routes) return;
|
||||
var routes = [];
|
||||
for (var route in this.routes) {
|
||||
routes.unshift([route, this.routes[route]]);
|
||||
}
|
||||
for (var i = 0, l = routes.length; i < l; i++) {
|
||||
this.route(routes[i][0], routes[i][1], this[routes[i][1]]);
|
||||
var route, routes = _.keys(this.routes);
|
||||
while ((route = routes.pop()) != null) {
|
||||
var name = this.routes[route];
|
||||
this.route(route, name, this[name]);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1393,14 +1391,14 @@
|
||||
|
||||
// For older servers, emulate HTTP by mimicking the HTTP method with `_method`
|
||||
// And an `X-HTTP-Method-Override` header.
|
||||
if (Backbone.emulateHTTP) {
|
||||
if (type === 'PUT' || type === 'DELETE') {
|
||||
if (Backbone.emulateJSON) params.data._method = type;
|
||||
params.type = 'POST';
|
||||
params.beforeSend = function(xhr) {
|
||||
xhr.setRequestHeader('X-HTTP-Method-Override', type);
|
||||
};
|
||||
}
|
||||
if (Backbone.emulateHTTP && (type === 'PUT' || type === 'DELETE')) {
|
||||
params.type = 'POST';
|
||||
if (Backbone.emulateJSON) params.data._method = type;
|
||||
var beforeSend = options.beforeSend;
|
||||
options.beforeSend = function(xhr) {
|
||||
xhr.setRequestHeader('X-HTTP-Method-Override', type);
|
||||
if (beforeSend) return beforeSend.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
// Don't process data on a non-GET request.
|
||||
@@ -1469,7 +1467,7 @@
|
||||
};
|
||||
|
||||
// Set up inheritance for the model, collection, router, and view.
|
||||
Model.extend = Collection.extend = Router.extend = View.extend = extend;
|
||||
Model.extend = Collection.extend = Router.extend = View.extend = History.extend = extend;
|
||||
|
||||
// Throw an error when a URL is needed, and none is supplied.
|
||||
var urlError = function() {
|
||||
|
||||
11
vendor/backbone/test/model.js
vendored
11
vendor/backbone/test/model.js
vendored
@@ -55,6 +55,17 @@ $(document).ready(function() {
|
||||
equal(model.get('value'), 2);
|
||||
});
|
||||
|
||||
test("parse can return null", 1, function() {
|
||||
var Model = Backbone.Model.extend({
|
||||
parse: function(obj) {
|
||||
obj.value += 1;
|
||||
return null;
|
||||
}
|
||||
});
|
||||
var model = new Model({value: 1}, {parse: true});
|
||||
equal(JSON.stringify(model.toJSON()), "{}");
|
||||
});
|
||||
|
||||
test("url", 3, function() {
|
||||
doc.urlRoot = null;
|
||||
equal(doc.url(), '/collection/1-the-tempest');
|
||||
|
||||
11
vendor/backbone/test/router.js
vendored
11
vendor/backbone/test/router.js
vendored
@@ -481,4 +481,15 @@ $(document).ready(function() {
|
||||
});
|
||||
});
|
||||
|
||||
test("#1746 - Router allows empty route.", 1, function() {
|
||||
var Router = Backbone.Router.extend({
|
||||
routes: {'': 'empty'},
|
||||
empty: function(){},
|
||||
route: function(route){
|
||||
strictEqual(route, '');
|
||||
}
|
||||
});
|
||||
new Router;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
24
vendor/backbone/test/sync.js
vendored
24
vendor/backbone/test/sync.js
vendored
@@ -17,6 +17,11 @@ $(document).ready(function() {
|
||||
Environment.prototype.setup.apply(this, arguments);
|
||||
library = new Library;
|
||||
library.create(attrs, {wait: false});
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
Environment.prototype.teardown.apply(this, arguments);
|
||||
Backbone.emulateHTTP = false;
|
||||
}
|
||||
|
||||
}));
|
||||
@@ -157,4 +162,23 @@ $(document).ready(function() {
|
||||
this.ajaxSettings.error();
|
||||
});
|
||||
|
||||
test("#1756 - Call user provided beforeSend function.", 4, function() {
|
||||
Backbone.emulateHTTP = true;
|
||||
var model = new Backbone.Model;
|
||||
model.url = '/test';
|
||||
var xhr = {
|
||||
setRequestHeader: function(header, value) {
|
||||
strictEqual(header, 'X-HTTP-Method-Override');
|
||||
strictEqual(value, 'DELETE');
|
||||
}
|
||||
};
|
||||
model.sync('delete', model, {
|
||||
beforeSend: function(_xhr) {
|
||||
ok(_xhr === xhr);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
strictEqual(this.ajaxSettings.beforeSend(xhr), false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user