@@ -8540,44 +8540,47 @@ this['DIFF_EQUAL'] = DIFF_EQUAL;
8540
8540
"use strict" ;
8541
8541
8542
8542
// modified from https://github.com/es-shims/es5-shim
8543
- var has = Object . prototype . hasOwnProperty ,
8544
- toString = Object . prototype . toString ,
8545
- isArgs = _dereq_ ( './isArguments' ) ,
8546
- hasDontEnumBug = ! ( { 'toString' : null } ) . propertyIsEnumerable ( 'toString' ) ,
8547
- hasProtoEnumBug = ( function ( ) { } ) . propertyIsEnumerable ( 'prototype' ) ,
8548
- dontEnums = [
8549
- "toString" ,
8550
- "toLocaleString" ,
8551
- "valueOf" ,
8552
- "hasOwnProperty" ,
8553
- "isPrototypeOf" ,
8554
- "propertyIsEnumerable" ,
8555
- "constructor"
8556
- ] ;
8543
+ var has = Object . prototype . hasOwnProperty ;
8544
+ var toString = Object . prototype . toString ;
8545
+ var isArgs = _dereq_ ( './isArguments' ) ;
8546
+ var hasDontEnumBug = ! ( { 'toString' : null } ) . propertyIsEnumerable ( 'toString' ) ;
8547
+ var hasProtoEnumBug = ( function ( ) { } ) . propertyIsEnumerable ( 'prototype' ) ;
8548
+ var dontEnums = [
8549
+ "toString" ,
8550
+ "toLocaleString" ,
8551
+ "valueOf" ,
8552
+ "hasOwnProperty" ,
8553
+ "isPrototypeOf" ,
8554
+ "propertyIsEnumerable" ,
8555
+ "constructor"
8556
+ ] ;
8557
8557
8558
8558
var keysShim = function keys ( object ) {
8559
- var isObject = object !== null && typeof object === 'object' ,
8560
- isFunction = toString . call ( object ) === '[object Function]' ,
8561
- isArguments = isArgs ( object ) ,
8562
- theKeys = [ ] ;
8559
+ var isObject = object !== null && typeof object === 'object' ;
8560
+ var isFunction = toString . call ( object ) === '[object Function]' ;
8561
+ var isArguments = isArgs ( object ) ;
8562
+ var isString = isObject && toString . call ( object ) === '[object String]' ;
8563
+ var theKeys = [ ] ;
8563
8564
8564
8565
if ( ! isObject && ! isFunction && ! isArguments ) {
8565
8566
throw new TypeError ( "Object.keys called on a non-object" ) ;
8566
8567
}
8567
8568
8568
- if ( isArguments ) {
8569
- for ( var key in object ) {
8570
- if ( has . call ( object , key ) ) {
8571
- theKeys . push ( Number ( key ) ) ;
8572
- }
8569
+ var skipProto = hasProtoEnumBug && isFunction ;
8570
+ if ( isString && object . length > 0 && ! has . call ( object , 0 ) ) {
8571
+ for ( var i = 0 ; i < object . length ; ++ i ) {
8572
+ theKeys . push ( String ( i ) ) ;
8573
8573
}
8574
- } else {
8575
- var name ,
8576
- skipProto = hasProtoEnumBug && isFunction ;
8574
+ }
8577
8575
8578
- for ( name in object ) {
8576
+ if ( isArguments && object . length > 0 ) {
8577
+ for ( var j = 0 ; j < object . length ; ++ j ) {
8578
+ theKeys . push ( String ( j ) ) ;
8579
+ }
8580
+ } else {
8581
+ for ( var name in object ) {
8579
8582
if ( ! ( skipProto && name === 'prototype' ) && has . call ( object , name ) ) {
8580
- theKeys . push ( name ) ;
8583
+ theKeys . push ( String ( name ) ) ;
8581
8584
}
8582
8585
}
8583
8586
}
@@ -8588,7 +8591,7 @@ var keysShim = function keys(object) {
8588
8591
8589
8592
for ( var j = 0 ; j < dontEnums . length ; ++ j ) {
8590
8593
if ( ! ( skipConstructor && dontEnums [ j ] === 'constructor' ) && has . call ( object , dontEnums [ j ] ) ) {
8591
- theKeys . push ( dontEnum ) ;
8594
+ theKeys . push ( dontEnums [ j ] ) ;
8592
8595
}
8593
8596
}
8594
8597
}
0 commit comments