Skip to content
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

use null prototype objects for languages/aliases #2636

Merged
merged 3 commits into from
Jul 21, 2020

Conversation

night
Copy link
Contributor

@night night commented Jul 20, 2020

getLanguage currently returns values for object prototype method names. By swapping to objects with a null prototype, we can fix this weird behavior.

Copy link
Member

@joshgoebel joshgoebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ok, but I'm curious did you run into a real life problem that you're trying to solve or...?

test/api/getLanguage.js Outdated Show resolved Hide resolved
@night
Copy link
Contributor Author

night commented Jul 21, 2020

Discord uses getLanguage to validate that a language specified exists in highlightJS and retrieve metadata about the language for code block highlighting in chat. Because highlightJS returns prototype values instead of the highlight languages themselves, the result is a few different bugs in our clients which expect the return type to be only Language | undefined.

@joshgoebel joshgoebel merged commit d8692db into highlightjs:master Jul 21, 2020
@joshgoebel
Copy link
Member

@night Thanks so much!

joshgoebel pushed a commit that referenced this pull request Jul 23, 2020
Fix: Discord uses getLanguage to validate that a language specified exists in highlightJS and retrieve metadata about the language for code block highlighting in chat. Because highlightJS returns prototype values instead of the highlight languages themselves, the result is a few different bugs in our clients which expect the return type to be only `Language | undefined`.
@renovate renovate bot mentioned this pull request Apr 9, 2022
1 task
@renovate renovate bot mentioned this pull request Jul 5, 2022
1 task
@renovate renovate bot mentioned this pull request Jul 25, 2022
1 task
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