Skip to content

Commit a5ed187

Browse files
committed
Fix: ignore properties of prototype
like `constructor`, `toString`, `valueOf`, etc.
1 parent e7d2cc4 commit a5ed187

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Diff for: lib/reserved-words.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ exports.check = function check(word, dialect, strict) {
4949

5050
assert(KEYWORDS[version], 'Unknown dialect');
5151

52-
return KEYWORDS[version][word];
52+
return KEYWORDS[version].hasOwnProperty(word);
5353
};
5454

5555
/**

Diff for: test/reserved-words.js

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ describe('reserved-words', function() {
2727
it('should return false for ES6 word', function() {
2828
assert(!reserved.check('await', dialect, strict));
2929
});
30+
31+
it('should return false for prototype word', function() {
32+
assert(!reserved.check('toString', dialect, strict));
33+
});
3034
});
3135

3236
describe('es5 dialect', function() {

0 commit comments

Comments
 (0)