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.

night added 2 commits Jul 20, 2020
@night night force-pushed the discord:master branch from e32b5ca to 214665d Jul 20, 2020
Copy link
Member

@joshgoebel joshgoebel left a comment

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 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
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@joshgoebel
Copy link
Member

@joshgoebel joshgoebel commented Jul 21, 2020

@night Thanks so much!

joshgoebel added 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`.
joshgoebel added a commit that referenced this pull request Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.