Simplify the _.support.dom check.

This commit is contained in:
John-David Dalton
2013-12-16 21:22:46 -08:00
parent fb432465ea
commit 39a8652708
9 changed files with 134 additions and 141 deletions

22
dist/lodash.compat.js vendored
View File

@@ -500,7 +500,7 @@
var reNative = RegExp('^' +
String(toString)
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
.replace(/toString| for [^\]]+/g, '.*?') + '$'
.replace(/\b(function)\b.*?(?=\\\()| for .+?(?=\\\])|\btoString\b/g, '$1.*?') + '$'
);
/** Native method shortcuts */
@@ -691,14 +691,6 @@
*/
support.argsObject = arguments.constructor == Object && !(arguments instanceof Array);
/**
* Detect if the DOM is supported.
*
* @memberOf _.support
* @type boolean
*/
support.dom = !!document && typeof document == 'object' && reNative.test(clearTimeout) && reNative.test(setTimeout);
/**
* Detect if `name` or `message` properties of `Error.prototype` are
* enumerable by default. (IE < 9, Safari < 5.1)
@@ -791,6 +783,18 @@
*/
support.unindexedChars = ('x'[0] + Object('x')[0]) != 'xx';
/**
* Detect if the DOM is supported.
*
* @memberOf _.support
* @type boolean
*/
try {
support.dom = document.createDocumentFragment().nodeType === 11;
} catch(e) {
support.dom = false;
}
/**
* Detect if a DOM node's [[Class]] is resolvable (all but IE < 9)
* and that the JS engine errors when attempting to coerce an object to