Skip to content

Commit

Permalink
fix to.keyword returning Object.prototype values (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
matias-la authored Apr 22, 2022
1 parent 4daceef commit 937b690
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var colorNames = require('color-name');
var swizzle = require('simple-swizzle');
var hasOwnProperty = Object.hasOwnProperty;

var reverseNames = {};
var reverseNames = Object.create(null);

// create a list of reverse color names
for (var name in colorNames) {
Expand Down
1 change: 1 addition & 0 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ assert.equal(string.to.hwb([280, 40, 60], 0.3), 'hwb(280, 40%, 60%, 0.3)');
assert.equal(string.to.hwb([280, 40, 60], 0), 'hwb(280, 40%, 60%, 0)');

assert.equal(string.to.keyword([255, 255, 0]), 'yellow');
assert.equal(string.to.keyword(['constructor']), undefined);
assert.equal(string.to.keyword([100, 255, 0]), undefined);

// Make sure .get() doesn't return object prototype values (regression test, #44)
Expand Down

0 comments on commit 937b690

Please sign in to comment.