8000 JS: Fixed variables named "async" (#1738) · PrismJS/prism@3560c64 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 3560c64

Browse files
JS: Fixed variables named "async" (#1738)
Fixes variables names "async" in JS.
1 parent c3862a2 commit 3560c64

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

components/prism-javascript.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Prism.languages.javascript = Prism.languages.extend('clike', {
1111
pattern: /((?:^|})\s*)(?:catch|finally)\b/,
1212
lookbehind: true
1313
},
14-
/\b(?:as|async|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/
14+
/\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/
1515
],
1616
'number': /\b(?:(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+)n?|\d+n|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,
1717
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)

components/prism-javascript.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prism.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ Prism.languages.javascript = Prism.languages.extend('clike', {
720720
pattern: /((?:^|})\s*)(?:catch|finally)\b/,
721721
lookbehind: true
722722
},
723-
/\b(?:as|async|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/
723+
/\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/
724724
],
725725
'number': /\b(?:(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+)n?|\d+n|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,
726726
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)

tests/languages/javascript/keyword_feature.test

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
catch finally;
2+
async function;
23

3-
as; async; await; break; case;
4+
as; await; break; case;
45
class; const; continue; debugger;
56
default; delete; do; else; enum;
67
export; extends; for;
7-
from; function; get; if; implements;
8+
from; get; if; implements;
89
import; in; instanceof; interface; let;
910
new; null; of; package; private;
1011
protected; public; return; set; static;
@@ -18,8 +19,10 @@ with; yield;
1819
["keyword", "catch"],
1920
["keyword", "finally"], ["punctuation", ";"],
2021

22+
["keyword", "async"],
23+
["keyword", "function"], ["punctuation", ";"],
24+
2125
["keyword", "as"], ["punctuation", ";"],
22-
["keyword", "async"], ["punctuation", ";"],
2326
["keyword", "await"], ["punctuation", ";"],
2427
["keyword", "break"], ["punctuation", ";"],
2528
["keyword", "case"], ["punctuation", ";"],
@@ -36,7 +39,6 @@ with; yield;
3639
["keyword", "extends"], ["punctuation", ";"],
3740
["keyword", "for"], ["punctuation", ";"],
3841
["keyword", "from"], ["punctuation", ";"],
39-
["keyword", "function"], ["punctuation", ";"],
4042
["keyword", "get"], ["punctuation", ";"],
4143
["keyword", "if"], ["punctuation", ";"],
4244
["keyword", "implements"], ["punctuation", ";"],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
let async = true;
2+
3+
----------------------------------------------------
4+
5+
[
6+
["keyword", "let"],
7+
" async ",
8+
["operator", "="],
9+
["boolean", "true"],
10+
["punctuation", ";"]
11+
]
12+
13+
----------------------------------------------------
14+
15+
Checks for variables with special names.

0 commit comments

Comments
 (0)
0