Condor
9 Dec 2009, 4:44 AM
Specifying 'null' as the scope for createDelegate will call the function with the scope set to 'window' instead of 'this' (see this post (http://www.extjs.com/forum/showthread.php?p=416979#post416979) for an example).
createCallback also uses 'window' instead of 'this' as the scope (I can't think of an example, but I recommend fixing it anyway).
It should be:
Ext.apply(Function.prototype, {
createDelegate : function(obj, args, appendArgs){
var method = this;
return function() {
var callArgs = args || arguments;
if (appendArgs === true){
callArgs = Array.prototype.slice.call(arguments, 0);
callArgs = callArgs.concat(args);
}else if (Ext.isNumber(appendArgs)){
callArgs = Array.prototype.slice.call(arguments, 0);
var applyArgs = [appendArgs, 0].concat(args);
Array.prototype.splice.apply(callArgs, applyArgs);
}
return method.apply(obj || this || window, callArgs);
};
},
createCallback : function(){
var args = arguments,
method = this;
return function() {
return method.apply(this || window, args);
};
}
});
(createInterceptor and createSequence already do this)
createCallback also uses 'window' instead of 'this' as the scope (I can't think of an example, but I recommend fixing it anyway).
It should be:
Ext.apply(Function.prototype, {
createDelegate : function(obj, args, appendArgs){
var method = this;
return function() {
var callArgs = args || arguments;
if (appendArgs === true){
callArgs = Array.prototype.slice.call(arguments, 0);
callArgs = callArgs.concat(args);
}else if (Ext.isNumber(appendArgs)){
callArgs = Array.prototype.slice.call(arguments, 0);
var applyArgs = [appendArgs, 0].concat(args);
Array.prototype.splice.apply(callArgs, applyArgs);
}
return method.apply(obj || this || window, callArgs);
};
},
createCallback : function(){
var args = arguments,
method = this;
return function() {
return method.apply(this || window, args);
};
}
});
(createInterceptor and createSequence already do this)