Skip to content

Commit 6e96542

Browse files
Fix an issue that caused the function returned by bind to error when its original function had no prototype property defined.
1 parent c8ef764 commit 6e96542

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/prototype/lang/function.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,14 @@ Object.extend(Function.prototype, (function() {
117117
var __method = this, args = slice.call(arguments, 1);
118118

119119
var bound = function() {
120-
var a = merge(args, arguments);
121-
var c = this instanceof nop ? this : context || window;
120+
var a = merge(args, arguments), c = context;
121+
// Ignore the supplied context when the bound function is called with
122+
// the "new" keyword.
123+
var c = this instanceof bound ? this : context || window;
122124
return __method.apply(c, a);
123-
}
124-
125-
nop.prototype = this.prototype;
125+
};
126+
127+
nop.prototype = this.prototype;
126128
bound.prototype = new nop();
127129

128130
return bound;

0 commit comments

Comments
 (0)