From 5de73f6c25202587fbf9d4d175dd9a4bc8d79e05 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Sat, 13 Nov 2010 18:08:02 -0500 Subject: [PATCH] coco 7222551: crushed __bind --- lib/nodes.js | 6 ++---- src/nodes.coffee | 4 +--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/nodes.js b/lib/nodes.js index 49232c5d..4abfbc53 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -7,9 +7,7 @@ for (var key in parent) if (__hasProp.call(parent, key)) child[key] = parent[key]; child.__super__ = parent.prototype; return child; - }, __bind = function(func, context) { - return function() { return func.apply(context, arguments); }; - }; + }, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; Scope = require('./scope').Scope; _ref = require('./helpers'), compact = _ref.compact, flatten = _ref.flatten, extend = _ref.extend, merge = _ref.merge, del = _ref.del, starts = _ref.starts, ends = _ref.ends, last = _ref.last; exports.extend = extend; @@ -1960,7 +1958,7 @@ }; UTILITIES = { "extends": 'function(child, parent) {\n function ctor() { this.constructor = child; }\n ctor.prototype = parent.prototype;\n child.prototype = new ctor;\n for (var key in parent) if (__hasProp.call(parent, key)) child[key] = parent[key];\n child.__super__ = parent.prototype;\n return child;\n}', - bind: 'function(func, context) {\n return function() { return func.apply(context, arguments); };\n}', + bind: 'function(fn, me){ return function(){ return fn.apply(me, arguments); }; }', indexOf: 'Array.prototype.indexOf || function(item) {\n for (var i = 0, l = this.length; i < l; i++) {\n if (this[i] === item) return i;\n }\n return -1;\n}', hasProp: 'Object.prototype.hasOwnProperty', slice: 'Array.prototype.slice' diff --git a/src/nodes.coffee b/src/nodes.coffee index 6e2bbb0b..c2e062e8 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1598,9 +1598,7 @@ UTILITIES = # Create a function bound to the current value of "this". bind: ''' - function(func, context) { - return function() { return func.apply(context, arguments); }; - } + function(fn, me){ return function(){ return fn.apply(me, arguments); }; } ''' # Discover if an item is in an array.