mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Avoid broken Function#bind in Narwhal.
This commit is contained in:
21
dist/lodash.compat.js
vendored
21
dist/lodash.compat.js
vendored
@@ -505,11 +505,14 @@
|
||||
/** Used to restore the original `_` reference in `noConflict` */
|
||||
var oldDash = context._;
|
||||
|
||||
/** Used to resolve the internal [[Class]] of values */
|
||||
var toString = objectProto.toString;
|
||||
|
||||
/** Used to detect if a method is native */
|
||||
var reNative = RegExp('^' +
|
||||
String(objectProto.valueOf)
|
||||
String(toString)
|
||||
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||
.replace(/valueOf|for [^\]]+/g, '.+?') + '$'
|
||||
.replace(/toString| for [^\]]+/g, '.*?') + '$'
|
||||
);
|
||||
|
||||
/** Native method shortcuts */
|
||||
@@ -525,10 +528,10 @@
|
||||
setImmediate = context.setImmediate,
|
||||
setTimeout = context.setTimeout,
|
||||
splice = arrayRef.splice,
|
||||
toString = objectProto.toString,
|
||||
unshift = arrayRef.unshift;
|
||||
|
||||
var defineProperty = (function() {
|
||||
// IE 8 that only accepts DOM elements
|
||||
try {
|
||||
var o = {},
|
||||
func = reNative.test(func = Object.defineProperty) && func,
|
||||
@@ -538,8 +541,7 @@
|
||||
}());
|
||||
|
||||
/* Native method shortcuts for methods with the same name as other `lodash` methods */
|
||||
var nativeBind = reNative.test(nativeBind = toString.bind) && nativeBind,
|
||||
nativeCreate = reNative.test(nativeCreate = Object.create) && nativeCreate,
|
||||
var nativeCreate = reNative.test(nativeCreate = Object.create) && nativeCreate,
|
||||
nativeIsArray = reNative.test(nativeIsArray = Array.isArray) && nativeIsArray,
|
||||
nativeIsFinite = context.isFinite,
|
||||
nativeIsNaN = context.isNaN,
|
||||
@@ -549,6 +551,15 @@
|
||||
nativeParseInt = context.parseInt,
|
||||
nativeRandom = Math.random;
|
||||
|
||||
var nativeBind = (function() {
|
||||
// Narwhal doesn't accept `undefined` as the `thisArg`
|
||||
try {
|
||||
var result = toString.bind;
|
||||
return reNative.test(result) && result.bind() && result;
|
||||
} catch(e) { }
|
||||
return false;
|
||||
}());
|
||||
|
||||
/** Detect various environments */
|
||||
var isIeOpera = reNative.test(context.attachEvent),
|
||||
isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera);
|
||||
|
||||
Reference in New Issue
Block a user