出于记录目的,我为元素函数属性创建了一个包装函数。包装函数在上面:
functionsWrapper: function () {
for (i = 0, args = new Array(arguments.length); i < arguments.length; i++) {
args[i] = arguments[i];
}
console.log('call for ' + arguments.callee.name + ' with params ' + argumantsLog(args));
return this['original' + arguments.callee.name].apply(this, args);
}
然后我使用这段代码来包装元素函数:
logFunctionsCalls: function (element) {
if (!element)
return;
if (element.children && element.children.length)
for (var i = 0; i < element.children.length; i++)
logFunctionsCalls(element.children[i]);
if (!element.functionsLogged) {
element.functionsLogged = true;
for (var property in element) {
if (typeof element[property] != 'function')
continue;
element['original' + property] = element[property];
element[property] = functionsWrapper;
}
}
}
我的问题是arguments.callee
包含functionsWrapper
没有被调用函数的属性名称的代码。