Skip to content

Commit

Permalink
use strict equality operator
Browse files Browse the repository at this point in the history
  • Loading branch information
maccman committed Jun 7, 2011
1 parent bbd85bb commit 9dcb8aa
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
12 changes: 6 additions & 6 deletions lib/spine.ajax.js
Expand Up @@ -4,7 +4,7 @@ var Model = Spine.Model;
var Ajax = Spine.Ajax = {
getUrl: function(object){
if (!(object && object.url)) return null;
return((typeof object.url == "function") ? object.url() : object.url);
return((typeof object.url === "function") ? object.url() : object.url);
},

methodMap: {
Expand All @@ -22,14 +22,14 @@ var Ajax = Spine.Ajax = {
data: {}
});

if (method == "create" && record.model)
if (method === "create" && record.model)
params.url = this.getUrl(record.parent);
else
params.url = this.getUrl(record);

if ( !params.url ) throw("Invalid URL");

if (method == "create" || method == "update") {
if (method === "create" || method === "update") {
var data = {};

if (record.parent.ajaxPrefix) {
Expand All @@ -46,7 +46,7 @@ var Ajax = Spine.Ajax = {
if ( !data ) return;

// Simple deep object comparison
if (JSON.stringify(record) == JSON.stringify(data)) return;
if (JSON.stringify(record) === JSON.stringify(data)) return;

// ID change, need to do some shifting
if (data.id && record.id != data.id) {
Expand All @@ -65,7 +65,7 @@ var Ajax = Spine.Ajax = {
};
}

if (method == "read" && !params.success)
if (method === "read" && !params.success)
params.success = function(data){
(record.refresh || record.load).call(record, data);
};
Expand Down Expand Up @@ -135,7 +135,7 @@ Model.extend({
Model.include({
url: function(){
var base = Ajax.getUrl(this.parent);
base += (base.charAt(base.length - 1) == "/" ? "" : "/");
base += (base.charAt(base.length - 1) === "/" ? "" : "/");
base += encodeURIComponent(this.id);
return base;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/spine.manager.js
Expand Up @@ -40,7 +40,7 @@ Manager.include({
if ( !controller ) throw("Controller required");

this.bind("change", function(current){
if (controller == current)
if (controller === current)
controller.activate();
else
controller.deactivate();
Expand All @@ -54,7 +54,7 @@ Manager.include({

Spine.Controller.include({
active: function(callback){
if (typeof callback == "function")
if (typeof callback === "function")
this.bind("active", callback)
else {
var args = Spine.makeArray(arguments);
Expand Down
10 changes: 5 additions & 5 deletions lib/spine.route.js
Expand Up @@ -19,7 +19,7 @@
history: false,

add: function(path, callback){
if (typeof path == "object")
if (typeof path === "object")
for(var p in path) this.add(p, path[p]);
else
this.routes.push(this.init(path, callback));
Expand Down Expand Up @@ -47,12 +47,12 @@
var args = Spine.makeArray(arguments);
var triggerRoutes = true;

if (typeof args[args.length - 1] == "boolean") {
if (typeof args[args.length - 1] === "boolean") {
triggerRoutes = args.pop();
}

var path = args.join("/");
if (this.path == path) return;
if (this.path === path) return;

if ( !triggerRoutes )
this.path = path;
Expand Down Expand Up @@ -88,7 +88,7 @@

change: function(e){
var path = (this.history ? this.getPath() : this.getFragment());
if (path == this.path) return;
if (path === this.path) return;
this.path = path;
for (var i=0; i < this.routes.length; i++)
if (this.routes[i].match(path)) return;
Expand All @@ -104,7 +104,7 @@
Route.include({
init: function(path, callback){
this.callback = callback;
if (typeof path == "string") {
if (typeof path === "string") {
path = path.replace(escapeRegExp, "\\$&")
.replace(namedParam, "([^\/]*)")
.replace(splatParam, "(.*?)");
Expand Down
10 changes: 5 additions & 5 deletions lib/spine.route.shim.js
Expand Up @@ -7,7 +7,7 @@ Route.extend({
routes: [],

add: function(path, callback){
if (typeof path == "object")
if (typeof path === "object")
for(var p in path) this.add(p, path[p]);
else
this.routes.push(this.init(path, callback));
Expand All @@ -23,12 +23,12 @@ Route.extend({
var args = Spine.makeArray(arguments);
var triggerRoutes = true;

if (typeof args[args.length - 1] == "boolean") {
if (typeof args[args.length - 1] === "boolean") {
triggerRoutes = args.pop();
}

var path = args.join("/");
if (this.path == path) return;
if (this.path === path) return;

if ( !triggerRoutes )
this.path = path;
Expand All @@ -39,7 +39,7 @@ Route.extend({
// Private

change: function(path){
if (path == this.path) return;
if (path === this.path) return;
this.path = path;
for (var i=0; i < this.routes.length; i++)
if (this.routes[i].match(path)) return;
Expand All @@ -53,7 +53,7 @@ var escapeRegExp = /[-[\]{}()+?.,\\^$|#\s]/g;
Route.include({
init: function(path, callback){
this.callback = callback;
if (typeof path == "string") {
if (typeof path === "string") {
path = path.replace(escapeRegExp, "\\$&")
.replace(namedParam, "([^\/]*)")
.replace(splatParam, "(.*?)");
Expand Down
2 changes: 1 addition & 1 deletion lib/spine.tabs.js
Expand Up @@ -55,7 +55,7 @@

connect: function(tabName, controller) {
this.bind("change", function(name){
if (name == tabName)
if (name === tabName)
controller.active();
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/spine.tmpl.js
Expand Up @@ -9,7 +9,7 @@ $.fn.item = function(){

$.fn.forItem = function(item){
return this.filter(function(){
var compare = $(this).tmplItem().data;
var compare = $(this).item();
if (item.eql && item.eql(compare) || item === compare)
return true;
});
Expand Down
18 changes: 9 additions & 9 deletions spine.js
Expand Up @@ -16,7 +16,7 @@
};

var isArray = Spine.isArray = function(value){
return Object.prototype.toString.call(value) == "[object Array]";
return Object.prototype.toString.call(value) === "[object Array]";
};

// Shim Array, as these functions aren't in IE
Expand Down Expand Up @@ -88,7 +88,7 @@

log: function(){
if ( !this.trace ) return;
if (typeof console == "undefined") return;
if (typeof console === "undefined") return;
var args = makeArray(arguments);
if (this.logPrefix) args.unshift(this.logPrefix);
console.log.apply(console, args);
Expand Down Expand Up @@ -153,7 +153,7 @@

include: function(obj){
for(var key in obj)
if (moduleKeywords.indexOf(key) == -1)
if (moduleKeywords.indexOf(key) === -1)
this.fn[key] = obj[key];

var included = obj.included;
Expand All @@ -163,7 +163,7 @@

extend: function(obj){
for(var key in obj)
if (moduleKeywords.indexOf(key) == -1)
if (moduleKeywords.indexOf(key) === -1)
this[key] = obj[key];

var extended = obj.extended;
Expand All @@ -181,7 +181,7 @@

Spine.guid = function(){
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);
return v.toString(16);
}).toUpperCase();
};
Expand Down Expand Up @@ -244,13 +244,13 @@

findByAttribute: function(name, value){
for (var key in this.records)
if (this.records[key][name] == value)
if (this.records[key][name] === value)
return this.records[key].clone();
},

findAllByAttribute: function(name, value){
return(this.select(function(item){
return(item[name] == value);
return(item[name] === value);
}));
},

Expand Down Expand Up @@ -306,7 +306,7 @@
},

fetch: function(callbackOrParams){
typeof(callbackOrParams) == "function" ?
typeof(callbackOrParams) === "function" ?
this.bind("fetch", callbackOrParams) :
this.trigger.apply(this, ["fetch"].concat(makeArray(arguments)));
},
Expand All @@ -317,7 +317,7 @@

fromJSON: function(objects){
if ( !objects ) return;
if ( typeof objects == "string" )
if ( typeof objects === "string" )
objects = JSON.parse(objects)
if ( isArray(objects) ) {
var results = [];
Expand Down

0 comments on commit 9dcb8aa

Please sign in to comment.