Skip to content

Commit

Permalink
prevented setter keyword conflicting with setTimeout|setInterval and …
Browse files Browse the repository at this point in the history
…highlighted them (#2514) (#2515)

* fix(javascript) prevent setter keyword 'set' conflicting with setTimeout|setInterval (#2514)
* enh(javascript) setTimeout|setInterval now highlighted (#2514)
* enh (javascript) clearInterval and clearTimeout now highlighted
* add keywords to TypeScript also
  • Loading branch information
qWici committed Apr 28, 2020
1 parent d4b047b commit ba2e65e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Expand Up @@ -13,6 +13,9 @@ Deprecations:

Language Improvements:

- enh(typescript) add setInterval, setTimeout, clearInterval, clearTimeout (#2514) [Josh Goebel][]
- enh(javascript) add setInterval, setTimeout, clearInterval, clearTimeout (#2514) [Vania Kucher][]
- fix(javascript) prevent `set` keyword conflicting with setTimeout, etc. (#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 All @@ -21,6 +24,7 @@ Language Improvements:
[Josh Goebel]: https://github.com/yyyc514
[Peter Plantinga]: https://github.com/pplantinga
[David Benjamin]: https://github.com/davidben
[Vania Kucher]: https://github.com/qWici


## Version 10.0.1
Expand Down
4 changes: 2 additions & 2 deletions src/languages/javascript.js
Expand Up @@ -33,7 +33,7 @@ export default function(hljs) {
'Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array ' +
'Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require ' +
'module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect ' +
'Promise'
'Promise setInterval setTimeout clearInterval clearTimeout'
};
var NUMBER = {
className: 'number',
Expand Down 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 Down
3 changes: 2 additions & 1 deletion src/languages/typescript.js
Expand Up @@ -25,7 +25,8 @@ export default function(hljs) {
'TypeError URIError Number Math Date String RegExp Array Float32Array ' +
'Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array ' +
'Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require ' +
'module console window document any number boolean string void Promise'
'module console window document any number boolean string void Promise ' +
'setInterval setTimeout clearInterval clearTimeout'
};
var DECORATOR = {
className: 'meta',
Expand Down
@@ -0,0 +1,2 @@
<span class="hljs-built_in">setTimeout</span>();
<span class="hljs-built_in">setInterval</span>();
2 changes: 2 additions & 0 deletions test/markup/javascript/keyword-as-part-of-method-name.txt
@@ -0,0 +1,2 @@
setTimeout();
setInterval();

0 comments on commit ba2e65e

Please sign in to comment.