Files
lodash/support.js
John-David Dalton 9b7c4d6761 Bump to v3.0.0.
2015-05-19 22:25:55 -07:00

77 lines
2.0 KiB
JavaScript

define(['./lang/isNative', './internal/root'], function(isNative, root) {
/** Used to detect functions containing a `this` reference. */
var reThis = /\bthis\b/;
/** Used for native method references. */
var objectProto = Object.prototype;
/** Used to detect DOM support. */
var document = (document = root.window) && document.document;
/** Native method references. */
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
/**
* An object environment feature flags.
*
* @static
* @memberOf _
* @type Object
*/
var support = {};
(function(x) {
/**
* Detect if functions can be decompiled by `Function#toString`
* (all but Firefox OS certified apps, older Opera mobile browsers, and
* the PlayStation 3; forced `false` for Windows 8 apps).
*
* @memberOf _.support
* @type boolean
*/
support.funcDecomp = !isNative(root.WinRTError) && reThis.test(function() { return this; });
/**
* Detect if `Function#name` is supported (all but IE).
*
* @memberOf _.support
* @type boolean
*/
support.funcNames = typeof Function.name == 'string';
/**
* Detect if the DOM is supported.
*
* @memberOf _.support
* @type boolean
*/
try {
support.dom = document.createDocumentFragment().nodeType === 11;
} catch(e) {
support.dom = false;
}
/**
* Detect if `arguments` object indexes are non-enumerable.
*
* In Firefox < 4, IE < 9, PhantomJS, and Safari < 5.1 `arguments` object
* indexes are non-enumerable. Chrome < 25 and Node.js < 0.11.0 treat
* `arguments` object indexes as non-enumerable and fail `hasOwnProperty`
* checks for indexes that exceed their function's formal parameters with
* associated values of `0`.
*
* @memberOf _.support
* @type boolean
*/
try {
support.nonEnumArgs = !propertyIsEnumerable.call(arguments, 1);
} catch(e) {
support.nonEnumArgs = true;
}
}(0, 0));
return support;
});