Skip to content

Commit 04afaf4

Browse files
authored
Merge pull request #3 from crowdin-modules/fix--allow-terms-that-are-also-the-names-of-JavaScript-builtins
allow terms that are also the names of JavaScript builtins
2 parents ad3ef2c + d2b9168 commit 04afaf4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Glossary {
2525
add (term, description) {
2626
assert(term && term.length, 'term is required')
2727
assert(description && description.length, 'description is required')
28-
assert(!(term in this._entries), `term ${term} has already been added`)
28+
assert(!(Object.keys(this.entries).includes(term)), `term ${term} has already been added`)
2929
this._entries[term] = description
3030
}
3131

test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ describe('glossary.add()', () => {
5656
glossary.add('IPC', 'inter-process communication')
5757
}).toThrow('term IPC has already been added')
5858
})
59+
60+
test('properly handles JS builtins like `constructor`', () => {
61+
glossary.add('constructor', 'a thing')
62+
glossary.add('toString', 'a thing')
63+
glossary.add('hasOwnProperty', 'a thing')
64+
})
5965
})
6066

6167
describe('glossary.webpage', () => {

0 commit comments

Comments
 (0)