Skip to content

Commit

Permalink
Use a hardcoded no-op instead of instancing
Browse files Browse the repository at this point in the history
The use of `new Function()` causes an EvalError if the environment's CSP
forbids execution of unsafe-eval. As there's no runtime evaluation being
performed, it's better to use a plain anonymous function instead.
  • Loading branch information
Alhadis committed Aug 23, 2017
1 parent 1ae9386 commit 31c3559
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/chai/utils/addProperty.js
Expand Up @@ -36,7 +36,7 @@ var transferFlags = require('./transferFlags');
*/

module.exports = function addProperty(ctx, name, getter) {
getter = getter === undefined ? new Function() : getter;
getter = getter === undefined ? function () {} : getter;

Object.defineProperty(ctx, name,
{ get: function propertyGetter() {
Expand Down

0 comments on commit 31c3559

Please sign in to comment.