Skip to content

Commit 27c2be0

Browse files
Don't inherit from the default Object for the token dictionary.
Ran into a problem tokenizing the string "[name] Constructors, LLC", since at some point `expandedToken` is `'constructor'`, which is valid default object function. aka ``` ({})['constructor'] > ƒ Object() { [native code] } ``` This uses a an object that doesn't inherent the Object functions for the `tokenDictionary`, getting around the issue.
1 parent 6404546 commit 27c2be0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

source/TokenHighlighter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class TokenHighlighter {
4040
highlight(text : string, tokens : Array<string>) {
4141
var tagsLength : number = this._wrapText('').length;
4242

43-
var tokenDictionary = {};
43+
var tokenDictionary = Object.create(null);
4444

4545
// Create a token map for easier lookup below.
4646
for (var i = 0, numTokens = tokens.length; i < numTokens; i++) {

0 commit comments

Comments
 (0)