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, var ArrayProto = Array.prototype,
ObjectProto = Object.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 */ /** Used to generate unique IDs */
var idCounter = 0; var idCounter = 0;
@@ -105,6 +98,7 @@
var concat = ArrayProto.concat, var concat = ArrayProto.concat,
hasOwnProperty = ObjectProto.hasOwnProperty, hasOwnProperty = ObjectProto.hasOwnProperty,
push = ArrayProto.push, push = ArrayProto.push,
propertyIsEnumerable = ObjectProto.propertyIsEnumerable,
slice = ArrayProto.slice, slice = ArrayProto.slice,
toString = ObjectProto.toString; toString = ObjectProto.toString;
@@ -127,6 +121,13 @@
var clearTimeout = window.clearTimeout, var clearTimeout = window.clearTimeout,
setTimeout = window.setTimeout; 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) */ /* 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)); var useNativeBind = nativeBind && /\n|Opera/.test(nativeBind + toString.call(window.opera));
@@ -2968,7 +2969,7 @@
*/ */
var keys = !nativeKeys ? shimKeys : function(object) { var keys = !nativeKeys ? shimKeys : function(object) {
// avoid iterating over the `prototype` property // avoid iterating over the `prototype` property
return typeof object == 'function' return typeof object == 'function' && propertyIsEnumerable.call(object, 'prototype')
? shimKeys(object) ? shimKeys(object)
: nativeKeys(object); : nativeKeys(object);
}; };