Skip to content

Commit 1f180fb

Browse files
committed
comments IE
1 parent b247bab commit 1f180fb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

underscore.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@
849849
// Object Functions
850850
// ----------------
851851

852-
// keys that won't be iterated by `for key in ...` and thus missed
852+
// Keys in IE that won't be iterated by `for key in ...` and thus missed.
853853
var hasEnumBug = !({toString: null}).propertyIsEnumerable('toString');
854854
var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString',
855855
'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
@@ -859,9 +859,12 @@
859859
_.keys = function(obj) {
860860
if (!_.isObject(obj)) return [];
861861
if (nativeKeys) return nativeKeys(obj);
862-
var keys = [], nonEnumIdx = 7;
862+
var keys = [];
863863
for (var key in obj) if (_.has(obj, key)) keys.push(key);
864+
865+
// Ahem, Internet Explorer.
864866
if (hasEnumBug) {
867+
var nonEnumIdx = nonEnumerableProps.length;
865868
while (nonEnumIdx--) {
866869
var prop = nonEnumerableProps[nonEnumIdx];
867870
if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop);

0 commit comments

Comments
 (0)