Skip to content

fix(javascript) fix set/get issue, add set/clear...Timeout/Interval keywords (#2514) #2515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 28, 2020
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Deprecations:

Language Improvements:

- enh(javascript) setTimeout|setInterval now highlighted (#2514) [Vania Kucher][]
- fix(javascript) prevent setter keyword `set` conflicting with setTimeout|setInterval (#2514) [Vania Kucher][]
- fix(cpp) Fix highlighting of unterminated raw strings (#2261) [David Benjamin][]
- fix(javascript) `=>` function with nested `()` in params now works (#2502) [Josh Goebel][]
- fix(typescript) `=>` function with nested `()` in params now works (#2502) [Josh Goebel][]
Expand Down
8 changes: 7 additions & 1 deletion src/languages/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export default function(hljs) {
beginKeywords: 'constructor', end: /\{/, excludeEnd: true
},
{
begin:'(get|set)\\s*(?=' + IDENT_RE+ '\\()',
begin: "(get|set)\\s+(?=" + IDENT_RE + "\\()",
end: /{/,
keywords: "get set",
contains: [
Expand All @@ -272,6 +272,12 @@ export default function(hljs) {
PARAMS
]

},
{
beginKeywords: "(setInterval|setTimeout)",
keywords: "setInterval setTimeout",
end: /\(/,
excludeEnd: true,
}
],
illegal: /#(?!!)/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<span class="hljs-keyword">setTimeout</span>();
<span class="hljs-keyword">setInterval</span>();
2 changes: 2 additions & 0 deletions test/markup/javascript/keyword-as-part-of-method-name.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
setTimeout();
setInterval();