Skip to content

Commit

Permalink
Linted select2/utils
Browse files Browse the repository at this point in the history
For the most part this was semicolon fixes, but there was a
function, `calledMethod`, which did need to be moved out of the
loop.
  • Loading branch information
kevin-brown committed Oct 22, 2014
1 parent ed6eb4f commit 898db2e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
4 changes: 4 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"bitwise": true,
"globals": {
"define": true
},
"indent": 2,
"maxlen": 80,
"quotmark": "single"
}
2 changes: 1 addition & 1 deletion src/js/jquery.shim.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
define(function () {
return jQuery;
})
});
47 changes: 24 additions & 23 deletions src/js/select2/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ define([], function () {
var Utils = {};

Utils.Extend = function (ChildClass, SuperClass) {
var __hasProp = {}.hasOwnProperty
var __hasProp = {}.hasOwnProperty;

function BaseConstructor () {
this.constructor = ChildClass;
Expand All @@ -29,7 +29,7 @@ define([], function () {
for (var methodName in proto) {
var m = proto[methodName];

if (typeof m !== "function") {
if (typeof m !== 'function') {
continue;
}

Expand Down Expand Up @@ -68,38 +68,39 @@ define([], function () {
DecoratedClass.prototype = new ctr();

for (var m = 0; m < superMethods.length; m++) {
var methodName = superMethods[m];
var superMethod = superMethods[m];

DecoratedClass.prototype[methodName] = SuperClass.prototype[methodName];
DecoratedClass.prototype[superMethod] =
SuperClass.prototype[methodName];
}

for (var m = 0; m < decoratedMethods.length; m++) {
var methodName = decoratedMethods[m];
var calledMethod = function (methodName) {
// Stub out the original method if it's not decorating an actual method
var originalMethod = function () {};

function calledMethod (methodName) {
// Stub out the original method if it's not decorating an actual method
var originalMethod = function () {};
if (methodName in DecoratedClass.prototype) {
originalMethod = DecoratedClass.prototype[methodName];
}

if (methodName in DecoratedClass.prototype) {
originalMethod = DecoratedClass.prototype[methodName];
}
var decoratedMethod = DecoratorClass.prototype[methodName];

var decoratedMethod = DecoratorClass.prototype[methodName];
return function () {
var unshift = Array.prototype.unshift;

return function () {
var unshift = Array.prototype.unshift;
unshift.call(arguments, originalMethod);

unshift.call(arguments, originalMethod);
return decoratedMethod.apply(this, arguments);
};
};

return decoratedMethod.apply(this, arguments);
}
}
for (var d = 0; d < decoratedMethods.length; d++) {
var decoratedMethod = decoratedMethods[d];

DecoratedClass.prototype[methodName] = calledMethod(methodName);
DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
}

return DecoratedClass;
}
};

var Observable = function () {
this.listeners = {};
Expand All @@ -120,8 +121,8 @@ define([], function () {
this.invoke(this.listeners[event], slice.call(arguments, 1));
}

if ("*" in this.listeners) {
this.invoke(this.listeners["*"], arguments);
if ('*' in this.listeners) {
this.invoke(this.listeners['*'], arguments);
}
};

Expand Down

0 comments on commit 898db2e

Please sign in to comment.