Skip to content

fix: highlight self as variable in JavaScript (fixes #4339)#4375

Open
KJyang-0114 wants to merge 1 commit intohighlightjs:mainfrom
KJyang-0114:fix/issue-4339-self-highlight
Open

fix: highlight self as variable in JavaScript (fixes #4339)#4375
KJyang-0114 wants to merge 1 commit intohighlightjs:mainfrom
KJyang-0114:fix/issue-4339-self-highlight

Conversation

@KJyang-0114
Copy link

Problem

The keyword self was not being highlighted as a language variable in JavaScript, unlike window and document.

Solution

Added self to the BUILT_IN_VARIABLES array in src/languages/lib/ecmascript.js.

Testing

  • Built the project successfully (npm run build)
  • All 1570 tests pass
  • Verified the fix works: hljs.highlight('self', {language: 'javascript'}).value now returns <span class="hljs-variable language_">self</span>

Checklist

  • Code changes are minimal and focused
  • Tests pass
  • Build succeeds

Self should be highlighted the same as window and document.
This fixes issue highlightjs#4339.
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.

1 participant