Add IE fallback for lack of Function#name.

Former-commit-id: 42047271fe596ed064ce2b1a58b70e6c6cd8a4af
This commit is contained in:
John-David Dalton
2013-08-27 22:24:46 -07:00
parent db605ea7ca
commit c6e2e33e87
7 changed files with 166 additions and 111 deletions

View File

@@ -56,6 +56,9 @@
/** Used to match regexp flags from their coerced string values */
var reFlags = /\w*$/;
/** Used to detected named functions */
var reFuncName = /^function[ \n\r\t]+\w/;
/** Used to match "interpolate" template delimiters */
var reInterpolate = /<%=([\s\S]+?)%>/g;
@@ -711,6 +714,15 @@
*/
support.fastBind = nativeBind && !isV8;
/**
* Detect if `Function#name` is supported (all but IE).
*
* @memberOf _.support
* @type boolean
*/
support.funcNames = typeof Function.name == 'string';
/**
* Detect if own properties are iterated after inherited properties (all but IE < 9).
*
@@ -1067,14 +1079,20 @@
if (typeof thisArg == 'undefined') {
return func;
}
var bindData = !func.name || func.__bindData__;
var bindData = func.__bindData__ || (support.funcNames && !func.name);
if (typeof bindData == 'undefined') {
// checks if `func` references the `this` keyword and stores the result
bindData = !reThis || reThis.test(fnToString.call(func));
setBindData(func, bindData);
var source = reThis && fnToString.call(func);
if (!support.funcNames && source && !reFuncName.test(source)) {
bindData = true;
}
if (support.funcNames || !bindData) {
// checks if `func` references the `this` keyword and stores the result
bindData = !reThis || reThis.test(source);
setBindData(func, bindData);
}
}
// exit early if there are no `this` references or `func` is bound
if (bindData !== true && !(bindData && bindData[1] & 1)) {
if (bindData !== true && (bindData && bindData[1] & 1)) {
return func;
}
switch (argCount) {