diff --git a/lib/nodes.js b/lib/nodes.js index 3383eb2a..93d80122 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -1496,7 +1496,7 @@ return "(" + (tests.join(' || ')) + ")"; }; In.prototype.compileLoopTest = function(o) { - return "" + (utility('inArray')) + "(" + (this.array.compile(o)) + ", " + (this.object.compile(o)) + ")"; + return "" + (utility('inArray')) + "(" + (this.object.compile(o)) + ", " + (this.array.compile(o)) + ")"; }; return In; })(); @@ -1962,7 +1962,7 @@ UTILITIES = { "extends": 'function(child, parent) {\n function ctor() { this.constructor = child; }\n ctor.prototype = parent.prototype;\n child.prototype = new ctor;\n if (typeof parent.extended === "function") parent.extended(child);\n child.__super__ = parent.prototype;\n}', bind: 'function(func, context) {\n return function() { return func.apply(context, arguments); };\n}', - inArray: '(function() {\n var indexOf = Array.prototype.indexOf || function(item) {\n var i = this.length; while (i--) if (this[i] === item) return i;\n return -1;\n };\n return function(array, item) { return indexOf.call(array, item) > -1; };\n})();', + inArray: '(function() {\n var indexOf = Array.prototype.indexOf || function(item) {\n var i = this.length; while (i--) if (this[i] === item) return i;\n return -1;\n };\n return function(item, array) { return indexOf.call(array, item) > -1; };\n})();', hasProp: 'Object.prototype.hasOwnProperty', slice: 'Array.prototype.slice' }; diff --git a/src/nodes.coffee b/src/nodes.coffee index d0acfa13..99e372a4 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1269,7 +1269,7 @@ exports.In = class In extends Base "(#{tests.join(' || ')})" compileLoopTest: (o) -> - "#{utility 'inArray'}(#{@array.compile o}, #{@object.compile o})" + "#{utility 'inArray'}(#{@object.compile o}, #{@array.compile o})" #### Try @@ -1678,7 +1678,7 @@ UTILITIES = var i = this.length; while (i--) if (this[i] === item) return i; return -1; }; - return function(array, item) { return indexOf.call(array, item) > -1; }; + return function(item, array) { return indexOf.call(array, item) > -1; }; })(); '''