Skip to content

Check if hljs is not null only once#458

Merged
rtfpessoa merged 1 commit intortfpessoa:masterfrom
ericcornelissen:check-hljs-once
Nov 4, 2022
Merged

Check if hljs is not null only once#458
rtfpessoa merged 1 commit intortfpessoa:masterfrom
ericcornelissen:check-hljs-once

Conversation

@ericcornelissen
Copy link
Copy Markdown
Contributor

While working on my previous contribution I noticed some // HACK: comments in the code. I thought I knew a solution so I figured I could contribute it - hope it helps 🙂

Let me know if you'd like to see anything changed.

Update the `highlightCode` method of `Diff2HtmlUI` to check if the hljs
reference is null only once (at the start). This address the "HACK"
comments by using a locally scoped variable for hljs. This way,
TypeScript is able to deduce that, after the initial null-check, hljs is
in fact not null.
@rtfpessoa rtfpessoa merged commit 7b6ee26 into rtfpessoa:master Nov 4, 2022
@ericcornelissen ericcornelissen deleted the check-hljs-once branch November 5, 2022 07:32
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.

2 participants