Skip to content

Commit

Permalink
fix: PhantomJS 1.x incompatibility (#966)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeber authored and lucasfcosta committed May 8, 2017
1 parent 850bd7e commit f3adfd9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/chai/utils/addChainableMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@ var canSetPrototype = typeof Object.setPrototypeOf === 'function';
// However, some of functions' own props are not configurable and should be skipped.
var testFn = function() {};
var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) {
return !Object.getOwnPropertyDescriptor(testFn, name).configurable;
var propDesc = Object.getOwnPropertyDescriptor(testFn, name);

// Note: PhantomJS 1.x includes `callee` as one of `testFn`'s own properties,
// but then returns `undefined` as the property descriptor for `callee`. As a
// workaround, we perform an otherwise unnecessary type-check for `propDesc`,
// and then filter it out if it's not an object as it should be.
if (typeof propDesc !== 'object')
return true;

return !propDesc.configurable;
});

// Cache `Function` properties
Expand Down

0 comments on commit f3adfd9

Please sign in to comment.