Skip to content

Commit

Permalink
Use Object#propertyIsEnumerable to default the initial "enumerable"…
Browse files Browse the repository at this point in the history
… value in `Object.getOwnPropertyDescriptor` sham.

Fixes #289.
  • Loading branch information
ljharb committed Jun 21, 2015
1 parent 061787f commit cd80ad1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions es5-sham.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
var call = Function.prototype.call;
var prototypeOfObject = Object.prototype;
var owns = call.bind(prototypeOfObject.hasOwnProperty);
var propertyIsEnumerable = call.bind(prototypeOfObject.propertyIsEnumerable);

// If JS engine supports accessors creating shortcuts.
var defineGetter;
Expand Down Expand Up @@ -120,9 +121,12 @@ if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
return descriptor;
}

// If object has a property then it's for sure both `enumerable` and
// `configurable`.
descriptor = { enumerable: true, configurable: true };
// If object has a property then it's for sure `configurable`, and
// probably `enumerable`. Detect enumerability though.
descriptor = {
enumerable: propertyIsEnumerable(object, property),
configurable: true
};

// If JS engine supports accessor properties then property may be a
// getter or setter.
Expand Down

0 comments on commit cd80ad1

Please sign in to comment.