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

Don't process language if block language not set #1410

Merged
merged 2 commits into from
Apr 29, 2018

Conversation

jwworth
Copy link
Contributor

@jwworth jwworth commented Apr 27, 2018

Adding this guard to the function prevents an error if the language is undefined. env.language.substring(0, 1).toUpperCase() can fail with Uncaught TypeError: Cannot read property 'substring' of undefined when env.language is undefined.

Adding this guard to the function prevents an error if the language is undefined. `env.language.substring(0, 1).toUpperCase()` can fail with `Uncaught TypeError: Cannot read property 'substring' of undefined` when `env.language` is undefined.
@mAAdhaTTah
Copy link
Member

This shouldn't go there. Right under it, you can see a conditional that checks a number of other things before it falls back to env.language. The check should go before that conditional.

jwworth added a commit to hashrocket/tilex that referenced this pull request Apr 27, 2018
@jwworth
Copy link
Contributor Author

jwworth commented Apr 27, 2018

Great point! I moved the conditional down, and added a check for language to ensure undefined isn't put into the span.

Copy link
Member

@mAAdhaTTah mAAdhaTTah left a comment

Choose a reason for hiding this comment

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

LGTM @Golmote see any issues?

@Golmote
Copy link
Contributor

Golmote commented Apr 28, 2018

No, LGTM too.

@mAAdhaTTah mAAdhaTTah merged commit 68d3c48 into PrismJS:gh-pages Apr 29, 2018
jwworth added a commit to hashrocket/tilex that referenced this pull request May 9, 2018
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.

3 participants