Skip to content

Commit 13f5dfa

Browse files
committed
Updated the list of reserved words for ES5. Fixes DFL-3445.
1 parent e728089 commit 13f5dfa

File tree

1 file changed

+53
-68
lines changed

1 file changed

+53
-68
lines changed

src/syntaxhighlight/js/syntax.js

Lines changed: 53 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -12,75 +12,61 @@ JSSyntax.is_valid_identifier = function(prop)
1212
{
1313
// This doesn't cover every allowed character, but should be fine most of the time
1414
return (/^[a-z$_][a-z$_0-9]*$/i.test(prop) && !js_keywords.hasOwnProperty(prop));
15-
}
15+
};
1616

17-
// TODO: make these static on JSSyntax
18-
var js_keywords=
19-
{
20-
'abstract': 1,
21-
'boolean': 1,
22-
'break': 1,
23-
'byte': 1,
24-
'case': 1,
25-
'catch': 1,
26-
'char': 1,
27-
'class': 1,
28-
'const': 1,
29-
'continue': 1,
30-
'debugger': 1,
31-
'default': 1,
32-
'delete': 1,
33-
'do': 1,
34-
'double': 1,
35-
'else': 1,
36-
'enum': 1,
37-
'export': 1,
38-
'extends': 1,
39-
'false': 1,
40-
'final': 1,
41-
'finally': 1,
42-
'float': 1,
43-
'for': 1,
44-
'function': 1,
45-
'goto': 1,
46-
'if': 1,
47-
'implements': 1,
48-
'import': 1,
49-
'in': 1,
50-
'instanceof': 1,
51-
'int': 1,
52-
'interface': 1,
53-
'let': 1,
54-
'long': 1,
55-
'native': 1,
56-
'new': 1,
57-
'null': 1,
58-
'package': 1,
59-
'private': 1,
60-
'protected': 1,
61-
'public': 1,
62-
'return': 1,
63-
'short': 1,
64-
'static': 1,
65-
'super': 1,
66-
'switch': 1,
67-
'synchronized': 1,
68-
'this': 1,
69-
'throw': 1,
70-
'throws': 1,
71-
'transient': 1,
72-
'true': 1,
73-
'try': 1,
74-
'typeof': 1,
75-
'var': 1,
76-
'void': 1,
77-
'while': 1,
78-
'with': 1,
79-
'yield': 1
80-
}
17+
// TODO: make this static on JSSyntax
18+
// TODO: rename to reserved_words
19+
var js_keywords = {
20+
// Keywords
21+
"break": 1,
22+
"do": 1,
23+
"instanceof": 1,
24+
"typeof": 1,
25+
"case": 1,
26+
"else": 1,
27+
"new": 1,
28+
"var": 1,
29+
"catch": 1,
30+
"finally": 1,
31+
"return": 1,
32+
"void": 1,
33+
"continue": 1,
34+
"for": 1,
35+
"switch": 1,
36+
"while": 1,
37+
"debugger": 1,
38+
"function": 1,
39+
"this": 1,
40+
"with": 1,
41+
"default": 1,
42+
"if": 1,
43+
"throw": 1,
44+
"delete": 1,
45+
"in": 1,
46+
"try": 1,
8147

82-
var js_builtins=
83-
{
48+
// Future reserved words
49+
"class": 1,
50+
"enum": 1,
51+
"extends": 1,
52+
"super": 1,
53+
"const": 1,
54+
"export": 1,
55+
"import": 1,
56+
57+
// Future reserved words in strict mode
58+
"implements": 1,
59+
"let": 1,
60+
"private": 1,
61+
"public": 1,
62+
"yield": 1,
63+
"interface": 1,
64+
"package": 1,
65+
"protected": 1,
66+
"static": 1
67+
};
68+
69+
var js_builtins = {
8470
'Anchor': 1,
8571
'anchors': 1,
8672
'Applet': 1,
@@ -122,4 +108,3 @@ var js_builtins=
122108
'window': 1
123109
};
124110

125-

0 commit comments

Comments
 (0)