mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Simplify _.isElement.
This commit is contained in:
@@ -153,9 +153,9 @@
|
|||||||
var contextProps = [
|
var contextProps = [
|
||||||
'Array', 'ArrayBuffer', 'Date', 'Error', 'Float32Array', 'Float64Array',
|
'Array', 'ArrayBuffer', 'Date', 'Error', 'Float32Array', 'Float64Array',
|
||||||
'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Number',
|
'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Number',
|
||||||
'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'document',
|
'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'isFinite',
|
||||||
'isFinite', 'parseFloat', 'parseInt', 'setTimeout', 'TypeError', 'Uint8Array',
|
'parseFloat', 'parseInt', 'setTimeout', 'TypeError', 'Uint8Array',
|
||||||
'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', 'window'
|
'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap'
|
||||||
];
|
];
|
||||||
|
|
||||||
/** Used to fix the JScript `[[DontEnum]]` bug. */
|
/** Used to fix the JScript `[[DontEnum]]` bug. */
|
||||||
@@ -732,9 +732,6 @@
|
|||||||
objectProto = Object.prototype,
|
objectProto = Object.prototype,
|
||||||
stringProto = String.prototype;
|
stringProto = String.prototype;
|
||||||
|
|
||||||
/** Used to detect DOM support. */
|
|
||||||
var document = (document = context.window) ? document.document : null;
|
|
||||||
|
|
||||||
/** Used to resolve the decompiled source of functions. */
|
/** Used to resolve the decompiled source of functions. */
|
||||||
var fnToString = Function.prototype.toString;
|
var fnToString = Function.prototype.toString;
|
||||||
|
|
||||||
@@ -1005,14 +1002,6 @@
|
|||||||
*/
|
*/
|
||||||
support.enumPrototypes = propertyIsEnumerable.call(Ctor, 'prototype');
|
support.enumPrototypes = propertyIsEnumerable.call(Ctor, 'prototype');
|
||||||
|
|
||||||
/**
|
|
||||||
* Detect if the `toStringTag` of DOM nodes is resolvable (all but IE < 9).
|
|
||||||
*
|
|
||||||
* @memberOf _.support
|
|
||||||
* @type boolean
|
|
||||||
*/
|
|
||||||
support.nodeTag = objToString.call(document) != objectTag;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect if properties shadowing those on `Object.prototype` are non-enumerable.
|
* Detect if properties shadowing those on `Object.prototype` are non-enumerable.
|
||||||
*
|
*
|
||||||
@@ -1058,17 +1047,6 @@
|
|||||||
*/
|
*/
|
||||||
support.unindexedChars = ('x'[0] + Object('x')[0]) != 'xx';
|
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;
|
|
||||||
}
|
|
||||||
}(1, 0));
|
}(1, 0));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -8574,14 +8552,7 @@
|
|||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
function isElement(value) {
|
function isElement(value) {
|
||||||
return !!value && value.nodeType === 1 && isObjectLike(value) &&
|
return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);
|
||||||
(lodash.support.nodeTag ? (objToString.call(value).indexOf('Element') > -1) : isHostObject(value));
|
|
||||||
}
|
|
||||||
// Fallback for environments without DOM support.
|
|
||||||
if (!support.dom) {
|
|
||||||
isElement = function(value) {
|
|
||||||
return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user