mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 17:47:49 +00:00
Update vendor/backbone.
Former-commit-id: dc1a37f3c44eecc1fcd1cba2018d70e8c337d6f3
This commit is contained in:
23
vendor/backbone/backbone.js
vendored
23
vendor/backbone/backbone.js
vendored
@@ -185,16 +185,16 @@
|
||||
var defaults;
|
||||
var attrs = attributes || {};
|
||||
if (options && options.collection) this.collection = options.collection;
|
||||
if (options && options.parse) attrs = this.parse(attrs);
|
||||
if (defaults = _.result(this, 'defaults')) {
|
||||
attrs = _.extend({}, defaults, attrs);
|
||||
}
|
||||
this.attributes = {};
|
||||
this._escapedAttributes = {};
|
||||
this.cid = _.uniqueId('c');
|
||||
this.changed = {};
|
||||
this._changes = {};
|
||||
this._pending = {};
|
||||
if (options && options.parse) attrs = this.parse(attrs);
|
||||
if (defaults = _.result(this, 'defaults')) {
|
||||
attrs = _.extend({}, defaults, attrs);
|
||||
}
|
||||
this.set(attrs, {silent: true});
|
||||
// Reset change tracking.
|
||||
this.changed = {};
|
||||
@@ -989,7 +989,7 @@
|
||||
};
|
||||
|
||||
// Cached regex for cleaning leading hashes and slashes.
|
||||
var routeStripper = /^[#\/]/;
|
||||
var routeStripper = /^[#\/]|\s+$/;
|
||||
|
||||
// Cached regex for stripping leading and trailing slashes.
|
||||
var rootStripper = /^\/+|\/+$/g;
|
||||
@@ -1365,7 +1365,10 @@
|
||||
var type = methodMap[method];
|
||||
|
||||
// Default options, unless specified.
|
||||
options || (options = {});
|
||||
_.defaults(options || (options = {}), {
|
||||
emulateHTTP: Backbone.emulateHTTP,
|
||||
emulateJSON: Backbone.emulateJSON
|
||||
});
|
||||
|
||||
// Default JSON-request options.
|
||||
var params = {type: type, dataType: 'json'};
|
||||
@@ -1382,16 +1385,16 @@
|
||||
}
|
||||
|
||||
// For older servers, emulate JSON by encoding the request into an HTML-form.
|
||||
if (Backbone.emulateJSON) {
|
||||
if (options.emulateJSON) {
|
||||
params.contentType = 'application/x-www-form-urlencoded';
|
||||
params.data = params.data ? {model: params.data} : {};
|
||||
}
|
||||
|
||||
// For older servers, emulate HTTP by mimicking the HTTP method with `_method`
|
||||
// And an `X-HTTP-Method-Override` header.
|
||||
if (Backbone.emulateHTTP && (type === 'PUT' || type === 'DELETE')) {
|
||||
if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE')) {
|
||||
params.type = 'POST';
|
||||
if (Backbone.emulateJSON) params.data._method = type;
|
||||
if (options.emulateJSON) params.data._method = type;
|
||||
var beforeSend = options.beforeSend;
|
||||
options.beforeSend = function(xhr) {
|
||||
xhr.setRequestHeader('X-HTTP-Method-Override', type);
|
||||
@@ -1400,7 +1403,7 @@
|
||||
}
|
||||
|
||||
// Don't process data on a non-GET request.
|
||||
if (params.type !== 'GET' && !Backbone.emulateJSON) {
|
||||
if (params.type !== 'GET' && !options.emulateJSON) {
|
||||
params.processData = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user