Add propertyIsEnumerable check to _.keys.

Former-commit-id: 1dcd532d29b3e99ce54a18f4489c766652d56d83
This commit is contained in:
John-David Dalton
2012-07-06 14:14:44 -04:00
parent 9d7136c63c
commit 6d217fc097

View File

@@ -41,13 +41,6 @@
var ArrayProto = Array.prototype,
ObjectProto = Object.prototype;
/**
* Detect the JScript [[DontEnum]] bug:
* In IE < 9 an objects own properties, shadowing non-enumerable ones, are
* made non-enumerable as well.
*/
var hasDontEnumBug = !{ 'valueOf': 0 }.propertyIsEnumerable('valueOf');
/** Used to generate unique IDs */
var idCounter = 0;
@@ -105,6 +98,7 @@
var concat = ArrayProto.concat,
hasOwnProperty = ObjectProto.hasOwnProperty,
push = ArrayProto.push,
propertyIsEnumerable = ObjectProto.propertyIsEnumerable,
slice = ArrayProto.slice,
toString = ObjectProto.toString;
@@ -127,6 +121,13 @@
var clearTimeout = window.clearTimeout,
setTimeout = window.setTimeout;
/**
* Detect the JScript [[DontEnum]] bug:
* In IE < 9 an objects own properties, shadowing non-enumerable ones, are
* made non-enumerable as well.
*/
var hasDontEnumBug = !propertyIsEnumerable.call({ 'valueOf': 0 }, 'valueOf');
/* Detect if `Function#bind` exists and is inferred to be fast (i.e. all but V8) */
var useNativeBind = nativeBind && /\n|Opera/.test(nativeBind + toString.call(window.opera));
@@ -2968,7 +2969,7 @@
*/
var keys = !nativeKeys ? shimKeys : function(object) {
// avoid iterating over the `prototype` property
return typeof object == 'function'
return typeof object == 'function' && propertyIsEnumerable.call(object, 'prototype')
? shimKeys(object)
: nativeKeys(object);
};