| 112 | | keys: function(object) { |
|---|
| 113 | | var keys = []; |
|---|
| 114 | | for (var property in object) |
|---|
| 115 | | keys.push(property); |
|---|
| 116 | | return keys; |
|---|
| 117 | | }, |
|---|
| | 109 | keys: (function() { |
|---|
| | 110 | var isDontEnumSkipped = true; |
|---|
| | 111 | var DontEnumProperties = [ |
|---|
| | 112 | 'toString', |
|---|
| | 113 | 'toLocaleString', |
|---|
| | 114 | 'valueOf', |
|---|
| | 115 | 'hasOwnProperty', |
|---|
| | 116 | 'isPrototypeOf', |
|---|
| | 117 | 'propertyIsEnumerable' |
|---|
| | 118 | ]; |
|---|
| | 119 | var length = DontEnumProperties.length; |
|---|
| | 120 | var hasOwnProperty = Object.prototype.hasOwnProperty; |
|---|
| | 121 | |
|---|
| | 122 | // IE does not enumerate over properties of an object |
|---|
| | 123 | // if there is a corresponding DontEnum property in a prototype chain |
|---|
| | 124 | for (var prop in { toString: true }) { |
|---|
| | 125 | isDontEnumSkipped = false; |
|---|
| | 126 | }; |
|---|
| | 127 | return function() { |
|---|
| | 128 | var keys = []; |
|---|
| | 129 | for (var property in object) { |
|---|
| | 130 | keys.push(property); |
|---|
| | 131 | } |
|---|
| | 132 | // if DontEnum is buggy, we check whether any |
|---|
| | 133 | // of the Object.prototype.* properties are "directly" in the object |
|---|
| | 134 | if (isDontEnumSkipped) { |
|---|
| | 135 | for (var i=0; i<length; i++) { |
|---|
| | 136 | if (hasOwnProperty.call(object, DontEnumProperties[i])) |
|---|
| | 137 | keys.push(DontEnumProperties[i]); |
|---|
| | 138 | } |
|---|
| | 139 | } |
|---|
| | 140 | return keys; |
|---|
| | 141 | } |
|---|
| | 142 | })(), |
|---|