Skip to content

fix(javascript): add 'self' as a built-in variable (#4339)#4410

Closed
xxiaoxiong wants to merge 1 commit into
highlightjs:mainfrom
xxiaoxiong:feat/js-self-variable-4339
Closed

fix(javascript): add 'self' as a built-in variable (#4339)#4410
xxiaoxiong wants to merge 1 commit into
highlightjs:mainfrom
xxiaoxiong:feat/js-self-variable-4339

Conversation

@xxiaoxiong
Copy link
Copy Markdown

@xxiaoxiong xxiaoxiong commented May 26, 2026

Problem

self is a standard Web API global available in both window and Worker contexts, equivalent to window in browsing contexts. However, the JavaScript grammar does not include self in its built-in variable list, so it is not syntax highlighted like other globals.

Changes

  • src/languages/javascript.js: Added 'self' to the BUILT_IN_VARIABLES array alongside existing entries like window, globalThis, and global.

Why

self is a standard Web API global (Window.self, WorkerGlobalScope.self). It should be highlighted consistently with other global objects for proper syntax clarity.

Closes #4339

'self' (Window.self) is a standard browser global that should be highlighted as a variable.language, consistent with 'window' and 'document'.
@xxiaoxiong xxiaoxiong closed this May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(Javascript) "self" should be highlighted?

1 participant