We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
bind
prototype
1 parent c8ef764 commit 6e96542Copy full SHA for 6e96542
src/prototype/lang/function.js
@@ -117,12 +117,14 @@ Object.extend(Function.prototype, (function() {
117
var __method = this, args = slice.call(arguments, 1);
118
119
var bound = function() {
120
- var a = merge(args, arguments);
121
- var c = this instanceof nop ? this : context || window;
+ var a = merge(args, arguments), c = context;
+ // Ignore the supplied context when the bound function is called with
122
+ // the "new" keyword.
123
+ var c = this instanceof bound ? this : context || window;
124
return __method.apply(c, a);
- }
-
125
- nop.prototype = this.prototype;
+ };
126
+
127
+ nop.prototype = this.prototype;
128
bound.prototype = new nop();
129
130
return bound;
0 commit comments