Skip to content

Commit

Permalink
Merge pull request #4146 from rafde/lodash5-compat
Browse files Browse the repository at this point in the history
`_.bind` to `Function.prototype.bind`
  • Loading branch information
jashkenas authored Dec 5, 2017
2 parents 06fd17a + 2276b8d commit 82bf61e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,15 @@
// once for each event, not once for a combination of all events.
Events.once = function(name, callback, context) {
// Map the event into a `{event: once}` object.
var events = eventsApi(onceMap, {}, name, callback, _.bind(this.off, this));
var events = eventsApi(onceMap, {}, name, callback, this.off.bind(this));
if (typeof name === 'string' && context == null) callback = void 0;
return this.on(events, callback, context);
};

// Inversion-of-control versions of `once`.
Events.listenToOnce = function(obj, name, callback) {
// Map the event into a `{event: once}` object.
var events = eventsApi(onceMap, {}, name, callback, _.bind(this.stopListening, this, obj));
var events = eventsApi(onceMap, {}, name, callback, this.stopListening.bind(this, obj));
return this.listenTo(obj, events);
};

Expand Down Expand Up @@ -1030,7 +1030,7 @@
options || (options = {});

var length = comparator.length;
if (_.isFunction(comparator)) comparator = _.bind(comparator, this);
if (_.isFunction(comparator)) comparator = comparator.bind(this);

// Run sort based on type of `comparator`.
if (length === 1 || _.isString(comparator)) {
Expand Down Expand Up @@ -1389,7 +1389,7 @@
if (!_.isFunction(method)) method = this[method];
if (!method) continue;
var match = key.match(delegateEventSplitter);
this.delegate(match[1], match[2], _.bind(method, this));
this.delegate(match[1], match[2], method.bind(this));
}
return this;
},
Expand Down Expand Up @@ -1744,7 +1744,7 @@
// falls back to polling.
var History = Backbone.History = function() {
this.handlers = [];
this.checkUrl = _.bind(this.checkUrl, this);
this.checkUrl = this.checkUrl.bind(this);

// Ensure that `History` can be used outside of the browser.
if (typeof window !== 'undefined') {
Expand Down

0 comments on commit 82bf61e

Please sign in to comment.