Skip to content

Commit

Permalink
Consistent use of === and void 0.
Browse files Browse the repository at this point in the history
  • Loading branch information
braddunbar committed Jul 18, 2012
1 parent 9ef2b3c commit ddefd21
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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});
Expand Down Expand Up @@ -735,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);
Expand Down Expand Up @@ -769,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) {
Expand Down Expand Up @@ -840,7 +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);
},

Expand All @@ -849,8 +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;
Expand Down Expand Up @@ -1042,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...
Expand Down Expand Up @@ -1080,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());
},
Expand Down Expand Up @@ -1113,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) {
Expand All @@ -1125,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.
Expand Down Expand Up @@ -1343,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);
}
Expand Down Expand Up @@ -1449,4 +1449,4 @@
throw new Error('A "url" property or function must be specified');
};

}).call(this);
}).call(this);

0 comments on commit ddefd21

Please sign in to comment.