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.js vendored
View File

@@ -474,7 +474,7 @@
var reNative = RegExp('^' +
String(toString)
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
.replace(/toString| for [^\]]+/g, '.*?') + '$'
.replace(/\b(function)\b.*?(?=\\\()| for .+?(?=\\\])|\btoString\b/g, '$1.*?') + '$'
);
/** Native method shortcuts */
@@ -620,14 +620,6 @@
*/
var support = lodash.support = {};
/**
* Detect if the DOM is supported.
*
* @memberOf _.support
* @type boolean
*/
support.dom = !!document && typeof document == 'object' && reNative.test(clearTimeout) && reNative.test(setTimeout);
/**
* Detect if functions can be decompiled by `Function#toString`
* (all but PS3 and older Opera mobile browsers & avoided in Windows 8 apps).
@@ -645,6 +637,18 @@
*/
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;
}
/**
* By default, the template delimiters used by Lo-Dash are similar to those in
* embedded Ruby (ERB). Change the following template settings to use alternative