mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Update vendor/underscore and backbone.
Former-commit-id: 614926653b0b1669f8a5533666adb0aecbd46c03
This commit is contained in:
47
vendor/backbone/backbone.js
vendored
47
vendor/backbone/backbone.js
vendored
@@ -295,7 +295,7 @@
|
||||
|
||||
// If the new and previous value differ, record the change. If not,
|
||||
// then remove changes for this attribute.
|
||||
if (!_.isEqual(prev[attr], val) || (_.has(now, attr) != _.has(prev, attr))) {
|
||||
if (!_.isEqual(prev[attr], val) || (_.has(now, attr) !== _.has(prev, attr))) {
|
||||
this.changed[attr] = val;
|
||||
if (!options.silent) this._pending[attr] = true;
|
||||
} else {
|
||||
@@ -432,7 +432,7 @@
|
||||
url: function() {
|
||||
var base = getValue(this, 'urlRoot') || getValue(this.collection, 'url') || urlError();
|
||||
if (this.isNew()) return base;
|
||||
return base + (base.charAt(base.length - 1) == '/' ? '' : '/') + encodeURIComponent(this.id);
|
||||
return base + (base.charAt(base.length - 1) === '/' ? '' : '/') + encodeURIComponent(this.id);
|
||||
},
|
||||
|
||||
// **parse** converts a response into the hash of attributes to be `set` on
|
||||
@@ -555,7 +555,7 @@
|
||||
var Collection = Backbone.Collection = function(models, options) {
|
||||
options || (options = {});
|
||||
if (options.model) this.model = options.model;
|
||||
if (options.comparator !== undefined) this.comparator = options.comparator;
|
||||
if (options.comparator !== void 0) this.comparator = options.comparator;
|
||||
this._reset();
|
||||
this.initialize.apply(this, arguments);
|
||||
if (models) this.reset(models, {silent: true, parse: options.parse});
|
||||
@@ -628,9 +628,7 @@
|
||||
// Merge in duplicate models.
|
||||
if (options.merge) {
|
||||
for (i = 0, length = dups.length; i < length; i++) {
|
||||
if (model = this._byId[dups[i].id]) {
|
||||
model.set(dups[i], options);
|
||||
}
|
||||
if (model = this._byId[dups[i].id]) model.set(dups[i], options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -737,7 +735,7 @@
|
||||
options || (options = {});
|
||||
if (!this.comparator) throw new Error('Cannot sort a set without a comparator');
|
||||
var boundComparator = _.bind(this.comparator, this);
|
||||
if (this.comparator.length == 1) {
|
||||
if (this.comparator.length === 1) {
|
||||
this.models = this.sortBy(boundComparator);
|
||||
} else {
|
||||
this.models.sort(boundComparator);
|
||||
@@ -771,7 +769,7 @@
|
||||
// models to the collection instead of resetting.
|
||||
fetch: function(options) {
|
||||
options = options ? _.clone(options) : {};
|
||||
if (options.parse === undefined) options.parse = true;
|
||||
if (options.parse === void 0) options.parse = true;
|
||||
var collection = this;
|
||||
var success = options.success;
|
||||
options.success = function(resp, status, xhr) {
|
||||
@@ -842,9 +840,7 @@
|
||||
|
||||
// Internal method to remove a model's ties to a collection.
|
||||
_removeReference: function(model) {
|
||||
if (this == model.collection) {
|
||||
delete model.collection;
|
||||
}
|
||||
if (this === model.collection) delete model.collection;
|
||||
model.off('all', this._onModelEvent, this);
|
||||
},
|
||||
|
||||
@@ -853,10 +849,8 @@
|
||||
// events simply proxy through. "add" and "remove" events that originate
|
||||
// in other collections are ignored.
|
||||
_onModelEvent: function(event, model, collection, options) {
|
||||
if ((event == 'add' || event == 'remove') && collection != this) return;
|
||||
if (event == 'destroy') {
|
||||
this.remove(model, options);
|
||||
}
|
||||
if ((event === 'add' || event === 'remove') && collection !== this) return;
|
||||
if (event === 'destroy') this.remove(model, options);
|
||||
if (model && event === 'change:' + model.idAttribute) {
|
||||
delete this._byId[model.previous(model.idAttribute)];
|
||||
if (model.id != null) this._byId[model.id] = model;
|
||||
@@ -1048,7 +1042,7 @@
|
||||
// opened by a non-pushState browser.
|
||||
this.fragment = fragment;
|
||||
var loc = this.location;
|
||||
var atRoot = (loc.pathname == this.options.root) && !loc.search;
|
||||
var atRoot = (loc.pathname === this.options.root) && !loc.search;
|
||||
|
||||
// If we've started off with a route from a `pushState`-enabled browser,
|
||||
// but we're currently in a browser that doesn't support it...
|
||||
@@ -1065,9 +1059,7 @@
|
||||
this.history.replaceState({}, document.title, loc.protocol + '//' + loc.host + this.options.root + this.fragment);
|
||||
}
|
||||
|
||||
if (!this.options.silent) {
|
||||
return this.loadUrl();
|
||||
}
|
||||
if (!this.options.silent) return this.loadUrl();
|
||||
},
|
||||
|
||||
// Disable Backbone.history, perhaps temporarily. Not useful in a real app,
|
||||
@@ -1088,10 +1080,10 @@
|
||||
// calls `loadUrl`, normalizing across the hidden iframe.
|
||||
checkUrl: function(e) {
|
||||
var current = this.getFragment();
|
||||
if (current == this.fragment && this.iframe) {
|
||||
if (current === this.fragment && this.iframe) {
|
||||
current = this.getFragment(this.getHash(this.iframe));
|
||||
}
|
||||
if (current == this.fragment) return false;
|
||||
if (current === this.fragment) return false;
|
||||
if (this.iframe) this.navigate(current);
|
||||
this.loadUrl() || this.loadUrl(this.getHash());
|
||||
},
|
||||
@@ -1121,9 +1113,9 @@
|
||||
if (!History.started) return false;
|
||||
if (!options || options === true) options = {trigger: options};
|
||||
var frag = (fragment || '').replace(routeStripper, '');
|
||||
if (this.fragment == frag) return;
|
||||
if (this.fragment === frag) return;
|
||||
this.fragment = frag;
|
||||
var url = (frag.indexOf(this.options.root) != 0 ? this.options.root : '') + frag;
|
||||
var url = (frag.indexOf(this.options.root) !== 0 ? this.options.root : '') + frag;
|
||||
|
||||
// If pushState is available, we use it to set the fragment as a real URL.
|
||||
if (this._hasPushState) {
|
||||
@@ -1133,7 +1125,7 @@
|
||||
// fragment to store history.
|
||||
} else if (this._wantsHashChange) {
|
||||
this._updateHash(this.location, frag, options.replace);
|
||||
if (this.iframe && (frag != this.getFragment(this.getHash(this.iframe)))) {
|
||||
if (this.iframe && (frag !== this.getFragment(this.getHash(this.iframe)))) {
|
||||
// Opening and closing the iframe tricks IE7 and earlier to push a
|
||||
// history entry on hash-tag change. When replace is true, we don't
|
||||
// want this.
|
||||
@@ -1158,6 +1150,7 @@
|
||||
location.hash = fragment;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Backbone.View
|
||||
@@ -1303,9 +1296,7 @@
|
||||
|
||||
// The self-propagating extend function that Backbone classes use.
|
||||
var extend = function(protoProps, classProps) {
|
||||
var child = inherits(this, protoProps, classProps);
|
||||
child.extend = this.extend;
|
||||
return child;
|
||||
return inherits(this, protoProps, classProps);
|
||||
};
|
||||
|
||||
// Set up inheritance for the model, collection, and view.
|
||||
@@ -1352,7 +1343,7 @@
|
||||
}
|
||||
|
||||
// Ensure that we have the appropriate request data.
|
||||
if (!options.data && model && (method == 'create' || method == 'update')) {
|
||||
if (!options.data && model && (method === 'create' || method === 'update')) {
|
||||
params.contentType = 'application/json';
|
||||
params.data = JSON.stringify(model);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user